Quantcast
Channel: Enabling SSH multiplexing for a series of commands, then closing it - Server Fault
Viewing all articles
Browse latest Browse all 2

Enabling SSH multiplexing for a series of commands, then closing it

$
0
0

I'm trying to create multiplexed ssh connections for a series of commands that run in succession, then after the series of commands is finished, close the multiplex session.

According to the documentation, the first connection should start the control master:

ssh -o "ControlMaster=auto" -S /home/justin/.ssh/sockets/multiplex_ssh.sock justin@1.2.3.4 "uptime"

Then the rest of the commands just need to pass:

ssh -S /home/justin/.ssh/sockets/multiplex_ssh.sock justin@1.2.3.4 "free -m"ssh -S /home/justin/.ssh/sockets/multiplex_ssh.sock justin@1.2.3.4 "hostname"ssh -S /home/justin/.ssh/sockets/multiplex_ssh.sock justin@1.2.3.4 "date"

Finally, to close the multiplex ssh session, I should be able to do:

ssh -O exit -S /home/justin/.ssh/sockets/multiplex_ssh.sock justin@1.2.3.4

Unfortunately, the first ssh command running ControlMaster=auto does not keep a socket active in the directory /home/justin/.ssh/sockets when passing a command to ssh. It instead immediately closes the socket.

How is this possible?


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>