SSH Coolness

I might be the last one to know this, but I just found a nifty feature in SSH. If you are logging into remote hosts with a different username from what you are using on the local system, and are doing that enough that typing the username each time is annoying, you can specify what user to log in as on a per host basis.


For example, I log in to my local machine as the user alan, but when I log into the machine workserver1 (which I do all the time) I use the username workusername. This means I’m always typing either ssh workusername@workserver1 or ssh workserver1 -l workusername, both of which are a) more typing than I want to do and b) I can easily forget, and have to start all over.


Solution, in my ~/.ssh/config file I have the following:


Host workserver1
User workusername

The end result is that when I type ssh workserver1 it automagically logs me in with the right username, saving me typing, time, and allowing more that many extra seconds of fingers left before their mean time to failure.


You can also have Host * entry for global settings.


Other options are available as well, see /etc/ssh/ssh_config of man ssh_config for a full list.