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 12:37:49 AEDT 2020

This is perhaps a problem with the documentation.

This command:

$ ssh <remote-host-name> echo  '`hostname`'

gets the strings "echo" and "`hostname`" as arguments, but on the server 
side "echo" is run with the argument "remote-host-name".

The ssh manpage says:

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

If "echo" is interpreted as a login shell, who interprets "`hostname`" 
as "remote-host-name" then, and why?

I found that in order to pass the string to the command run on the 
remote host verbatim it is necessary to escape every character in it, 
but it isn't clear why should this be necessary.

Perhaps this should be explained in the manpage.


More information about the openssh-unix-dev mailing list