Making SSH connections to your frequent remote hosts faster with ControlMaster

by Phil Dufault on August 5, 2008 · 7 comments

in Featured,Linux,Shell

I have recently learned of a new OpenSSH feature that allows you to reuse your  existing SSH connections to hosts.  Since you’re saving time on the encryption handshake, you connect to where you want, faster.

If you want to enable this functionality on a per-host basis, then you can setup your ~/.ssh/config file like this:
Host *
ControlMaster no
ControlPath ~/.ssh/master-%l-%h-%p-%r.sock
Host someserver
Compression yes
ControlMaster yes

To enable it:
ssh -f -N someserver

After that, just ssh in like you would normally:
ssh someserver

Combining this with SSH keys and keychain — that’s some fast SSHing. Enjoy!

Source for this article: http://www.revsys.com/writings/quicktips/ssh-faster-connections.html

{ 7 comments… read them below or add one }

Mike August 11, 2008 at 9:57 am

I had no idea this was possible, too bad it’s only if you’re using the UNIX SSH command, would be awesome to have something like this on windows.

Phil Dufault August 11, 2008 at 9:59 am

Might be possible to use the ssh client that comes with Cygwin to do this, Mike. Not sure though. :)

Chloe@Highchairs September 5, 2008 at 12:59 am

I use win when at work and putty for ssh’ing into the remote servers, do you know how these settings can be put into putty?

Phil Dufault September 5, 2008 at 1:11 am

Unfortunately, this feature is only available in OpenSSH. PuTTY doesn’t have this feature.

Andrew Johnson November 18, 2008 at 11:05 pm

Interesting, and cool! Thanks Phil =)

Look forward to more SSH tips.

Andrew Johnson November 18, 2008 at 11:07 pm

Interesting, and cool! Thanks Phil =)

Look forward to more SSH tips & tricks.

Jon Daley February 3, 2009 at 7:51 am

I also recently learned about this (thanks Linux Journal), but they have an improvement on your steps. If you set ControlMaster to auto, it will do the right thing, whether or not a previous connection already exists.

That way, the first time you connect, it does the normal thing and asks for a password or passphrase, etc. but the second time it doesn’t.

I haven’t tried it, but I suspect that I wouldn’t really like the -f -N method.

Leave a Comment

Previous post:

Next post: