ssh.c 1.449 breaks ProxyJump/-J when user shell is zsh

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

ssh.c 1.449 breaks ProxyJump/-J when user shell is zsh

Lauri Tirkkonen-2
The latest revision for ssh.c added [] brackets around the hostname in
the ProxyJump/-J command:

However, as [] are shell metacharacters and the ProxyCommand is executed
using $SHELL -c, this doesn't work when $SHELL is zsh (although there
may be different zsh configurations where it does work):

% ssh -J localhost localhost
zsh:1: no matches found: [localhost]:22
ssh_exchange_identification: Connection closed by remote host

Adding quotes to the command works works around this (diff below) but it
does this by using more shell metacharacters which might not be a good
solution as it's just as likely shell specific. Perhaps ProxyJump (as
opposed to ProxyCommand) should execute ssh directly instead of the user

Index: ssh.c
RCS file: /cvs/src/usr.bin/ssh/ssh.c,v
retrieving revision 1.449
diff -u -p -r1.449 ssh.c
--- ssh.c 17 Feb 2017 02:04:15 -0000 1.449
+++ ssh.c 2 Mar 2017 13:44:59 -0000
@@ -1072,7 +1072,7 @@ main(int ac, char **av)
  options.proxy_use_fdpass = 0;
  snprintf(port_s, sizeof(port_s), "%d", options.jump_port);
-    "ssh%s%s%s%s%s%s%s%s%s%.*s -W [%%h]:%%p %s",
+    "ssh%s%s%s%s%s%s%s%s%s%.*s -W '[%%h]':%%p %s",
     /* Optional "-l user" argument if jump_user set */
     options.jump_user == NULL ? "" : " -l ",
     options.jump_user == NULL ? "" : options.jump_user,

Lauri Tirkkonen | lotheac @ IRCnet