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?

Thorsten Glaser t.glaser at tarent.de
Sun Jan 12 04:07:01 AEDT 2020


On Sat, 11 Jan 2020, Yuri wrote:

> On 2020-01-11 08:57, Thorsten Glaser wrote:
> > If you wish for no local expansion, quote locally, such as:
> > 
> > ssh -l luser remotehost '
> > 	command1
> > 	command2
> > 	…
> > '

> This didn't work for me because single quotes only prevent local expansion.

Then you didn’t do it right.

> The string is expanded on the remote host.

Yes, “command1” is expanded remotely, but you use the quoting rules
of the remote shell INSIDE the single quotes for the local POSIX shell
to prevent that (just replace all ' with '\'' and you’re set).

bye,
//mirabilos
-- 
tarent solutions GmbH
Rochusstraße 2-4, D-53123 Bonn • http://www.tarent.de/
Tel: +49 228 54881-393 • Fax: +49 228 54881-235
HRB 5168 (AG Bonn) • USt-ID (VAT): DE122264941
Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg


More information about the openssh-unix-dev mailing list