Contributed by todd on from the when-you-just-want-an-example dept.
Back when OpenSSH 4.2 was released, the first item mentioned under bugfixes and improvements was about the ControlMaster=auto/autoask option having been added to support opportunistic multiplexing. Aside from being a mouthful, you might wonder what this means.
By adding this to my $HOME/.ssh/config file:
Host * ControlPath ~/.ssh/ctl-%r-%h-%p ControlMaster auto
.. I ssh to a machine named 'eclipse' in one xterm on my laptop:
todd@blue/p7 4126$ ssh eclipse todd@eclipse's password: Last login: Wed Sep 14 11:46:00 2005 from blue.isp.fries.net OpenBSD 3.8 (GENERIC) #130: Mon Aug 29 11:40:56 MDT 2005 todd@eclipse/p0 1$
So far, nothing is different. Or is it? Back on my laptop, I see this new file created:
todd@blue/p8 3966$ ls -l $HOME/.ssh/ctl-todd-eclipse-22 srw------- 1 todd todd 0 Sep 14 23:18 /u/todd/.ssh/ctl-todd-eclipse-22= todd@blue/p8 3967$
This is a 'socket' denoted by the 's' on the far left of the filename. With this, subsequent ssh connections to eclipse from my laptop will use the socket and utilize the existing connection instead of establishing a new one:
todd@blue/p8 3967$ ssh -v eclipse OpenSSH_4.1, OpenSSL 0.9.7g 11 Apr 2005 debug1: Reading configuration data /u/todd/.ssh/config debug1: Applying options for * debug1: Reading configuration data /etc/ssh/ssh_config debug1: auto-mux: Trying existing master Last login: Wed Sep 14 23:17:03 2005 from blue.wfi.fries.net OpenBSD 3.8 (GENERIC) #130: Mon Aug 29 11:40:56 MDT 2005 todd@eclipse/p1 1$
This has really saved me a lot of time since I started using this new functionality. If you are a regular user of ssh on a unix system, I suspect it will save you time as well!
Disclaimer: Only available via Protocol 2, limit of 10 connections per socket.
(Comments are closed)