remote command word splitting
Damien Miller
djm at mindrot.org
Thu Dec 2 09:48:22 EST 2004
frederik at a5.repetae.net wrote:
> Hello,
>
> I have a suggestion about the way ssh does word splitting on commands
> which have been passed to it for remote execution.
ssh doesn't do splitting. You local shell does it and ssh just passes
the result to a remote shell, which may do its own splitting.
> It appears that
> what is currently done is, if there are extra arguments on the ssh
> command line for a remote command, (1) split each of these arguments
> into a list (2) concatenate the resulting lists to get the command
> arguments. So we get behavior like
>
> $ perl -le 'die "hi"'
> hi at -e line 1.
> $ ssh some-host perl -le 'die "hi"'
> Died at -e line 1.
You local shell will be eating the outermost set of quotes before ssh
touches it. If you explicitly quote your commandline, then you can avoid
any problems:
[djm at baragon djm]$ ssh djm@::1 "perl -le 'die \"hi\"'"
hi at -e line 1.
Maybe the way that ssh reconstructs the argument string to send to the
server could be changed to insert quotes around arguments with spaces in
them, but that would require ssh to examine the commands themselves. I
don't think that this is acceptable because it means that ssh would
magically muck with your command behind your back. I have no doubt that
this would break people's scripts.
> Also, importantly, I think this suggestion would be mostly backwards
> compatible, although others might have a better sense of this. It
> might not be wise to make it the default
Sorry, but we won't be adding different "modes" to modify the
commandline - that is a useless knob when you can just quote it
explicitly.
-d
More information about the openssh-unix-dev
mailing list