Write SSH command over multiple lines

ssh is in fact just passing a string to the remote host. There this string is given to a shell which is supposed to interpret it (the user’s login shell, which is typically something like bash). So whatever you want to execute needs to be interpretable by that remote login shell, that’s the whole rule you have to stick to.

You can indeed just use newlines within the command string:

ssh alfe@sweethome "
  ls /home/alfe/whatever
  ping foreignhost
  date
  rm foobar
"

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)