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 web.iiit.ac.in 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 *.iiit.ac.in 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 “*.iiit.ac.in”,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 "*.iiit.ac.in,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 http://fermiparadox.wordpress.com/2008/06/19/ssh-connection-sharing/. 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 web.iiit.ac.in” to login.
Edit:
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.
Host bitbucket.org
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.
Host *.iiit.ac.in 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 “*.iiit.ac.in”,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 "*.iiit.ac.in,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 http://fermiparadox.wordpress.com/2008/06/19/ssh-connection-sharing/. 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 web.iiit.ac.in” to login.
Edit:
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.
Host bitbucket.org
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.
Comments
Post a Comment