Some useful SSH configurations

Lately I was tired of having to repeatedly type my user name for my ssh connections. In my current setup I often ssh to two servers inside the IIIT (my college) network. merely typing ssh would try to use the username as my local computer’s login user name. So I was trying to get a workaround for this. A simple approach would be to rename my local computer’s user name to the IIIT server user name , but now that would be very lame. So I figured there must be some simple configuration available and looked up man ssh_config which gave an extremely detailed list of all the possible configuration options. Finally my configuration file looked like this :

Host * mirage web
User iiit_login_user
Host *
ControlMaster auto
ControlPath /home/phinfinity/.ssh/%r@%h:%p
GSSAPIAuthentication no

The first line specifies the categories for which the configuration below are to be used. Here I have specified the configuration to be applied for 3 possible categories “*”,mirage,web . mirage and web being two of the servers. There seems to be some misinterpretation in the man page which expects the actual format to be :

Host "*,mirage,web"

However space-separation works unlike comma-separations as specified in the manual. The User iiit_login_user specifies the default user to use if none are specified.
The remaining lines are my default lines applicable for all Hosts. In particular one very useful configuration I discovered from It is an Excellent setup to make secondary connection’s password less using a primary connection established initially. In addition I also added Public/Private key setup so that I can login password-less to the servers I use often. Now I merely have to type “ssh” to login.

There’s also a useful ControlPersist option which allows the connection to persist beyond the original connection. This allows the connection to remain for a set period of time of inactivity.

ControlPersist 600

I don’t prefer to enable this for all Hosts, so you might want to specifically use this only for some hosts. The above code allows connections to persist for 600seconds of inactivity without an active ssh session.

Posted in Uncategorized
One comment on “Some useful SSH configurations
  1. Madhavan says:

    Useful indeed, 3 and a half years since writing – still made my day. Used these while at college. Glad you put these down here. Saved me time today!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: