Category: ssh

SSH Session Multiplexing

I have a new favorite ssh feature! Not that password-less public key authentication, port forwarding or X11 forwarding weren't really cool. But session multiplexing is really sweet.

Included in version 3.9, session multiplexing is a faster way to run multiple ssh session to a single remote host. When you login to a machine (call it 'remotehost') the first time, you tell that ssh session to become the "ControlMaster" (-M option).

# ssh -M -S ~/.ssh/remote-mux user@remotehost
Ssh will start a session as usual and also open up a Unix domain socket using the filename you provide in the ControlPath argument (-S option).

To start another ssh session to the same host, you can do:

# ssh -S ControlPath=~/.ssh/remote-mux user@remotehost
Ssh will skip authentication (as you've already auth'd to remotehost) and will use the existing TCP connection for the second connection. The upshot of this is that logging in a second (or third!) time is instantaneous.

Adding the -S and -M options on the command line is tedious. You can setup your .ssh/config file like this:

Host remotehost
   HostName remotehost
   User user
   ControlMaster yes
   ControlPath ~/.ssh/remote-mux

Host remotehostfast
   HostName remotehost
   User user
   ControlMaster no
   ControlPath ~/.ssh/remote-mux
For your first connection, do:
# ssh remotehost
For your subsequent connections, do:
# ssh remotehostfast

Link to story

Technorati tags for this post:

< Future 10 | Past 10 >