Certain servers I connect to on a regular basis are rather slow when connecting. Here are some ~/.ssh/config options to speed up ssh connections.

I find this is useful for scripts that make multiple subsequent ssh connections. Capistrano comes to mind as well as a couple of scripts I have that use scp.

Host * # don't try to authenticate with Kerberos GSSAPIAuthentication no GSSAPIKeyExchange no # persist the ssh connection for 5 minutes # subsequent ssh connections respond faster because its reusing an existing connection ControlMaster auto ControlPath ~/.ssh/master-%r@%h:%p ControlPersist 5m

Beware Strange Behavior

I have noticed occasionally that I get some error messages due to stale master connections. I think this happens when my computer powers off without shutting down fully.

Control socket connect(/Users/eric/.ssh/master-user@example.com:22): Connection refused ControlSocket /Users/eric/.ssh/master-user@example.com:22 already exists, disabling multiplexing

The connection still works, but it is even slower to connect which defeats the purpose of using master control sockets. You can go into ~/.ssh and manually remove the connection files to clean it up.

Furthermore, this behavior can get quite confusing when setting up ssh-key authentication. You may think you have it set up correctly because of lack of a password prompt, but in my case it was reusing the connection (which is why it didn't prompt me).