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?

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.