Why are the arguments supplied for the command run through ssh interpreted by shell before they are passed to the command on the server side?

Yuri yuri at rawbw.com
Sat Jan 11 20:59:33 AEDT 2020


On 2020-01-11 01:38, Darren Tucker wrote:
> The command you give is always handled on the server by your shell in some
> fashion.  It has to be, because SSH only specifies an opaque string for the
> remote command, so without doing so you would not be able to specify
> arguments at all.


It's not obvious why does it have to be this way. ssh sends the command 
as an array of strings. The first string is the command, and the 
subsequent strings are arguments. It can easily call the same command 
with the same arguments on the remote host.


Also this sentence from the man page seems to be false:

 > If a command is specified, it is executed on the remote host instead 
of a login shell.

Login shell still interprets the command. Interestingly, the shell 
process isn't running on the remote host, the command is a direct child 
of sshd.


Yuri




More information about the openssh-unix-dev mailing list