0

I'm trying to find a clean way to run multiple commands through an SSH connection. I'm using the common:

$ ssh USER@HOST 'COMMAND1; COMMAND2; COMMAND3'

for example

$ ssh USER@HOST 'cd /var/www; git status'

After I run this command, I get the normal prompt. Does this means the SSH connection was terminated after executing the commands?

  • Indeed the connection gets closed. So if abusing SSH for running remote commands, see this https://unix.stackexchange.com/questions/381974/multiple-commands-during-an-ssh-inside-an-ssh-session/381980#381980 – Rui F Ribeiro Feb 26 '19 at 12:59

1 Answers1

0

From man ssh:

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

[...]

The session terminates when the command or shell on the remote machine exits and all X11 and TCP connections have been closed.

So yes, the SSH connection gets closed after the execution of your specified commands.

Panki
  • 6,221
  • 2
  • 24
  • 33