ssh "bash -c" bug

Bob Proulx bob at proulx.com
Thu Feb 21 11:48:26 EST 2013


Олохтонов Владимир wrote:
> The arguments of the first command given to "bash -c" over ssh is
> being ignored.
> 
> xxx at yyy:~$ ssh xxx at localhost bash -c 'echo foo; echo bar'

Instead of confusing shell quoting I recommend piping the commands to
the remote shell.  Used judiciously it can avoid confusion.

  $ echo "echo foo; echo bar" | ssh xxx at example bash

Or:

  $ ssh xxx at example bash <<'EOF'
  echo foo; echo bar
  EOF

One of the useful features of this method is that the shell
interpreter on the remote system is specified and does not use the
default login shell from the password file.  Useful when your login on
some hosts is different than on others.

Bob


More information about the openssh-unix-dev mailing list