Make connecting using ssh easier with .ssh/config

When working in an environment where the systems you work on require ssh access, it can get quite tedious after a while if you have to type in the whole servername over and over again into your terminal window. Thankfully, there is a config file that makes that a bit easier.

Normally, coming to work in the morning I would type in the following to connect to my development machine:
ssh servername.my.awesome.company.com

That is a lot of typing if you ask me :-). So I found out about ~/.ssh/config which gives you the opportunity to define aliases for hosts you would like to connect to using ssh. You simply open ~/.ssh/config in vi and add the following:

Host myalias
HostName servername.my.awesome.company.com

So next time you would like to connect to your host, all you need to type is:
ssh myalias

I have to agree with Dave Child’s blogpost: Developers are lazy.

In addition to that and to further automate the login process, you could then add additional commands you would like to get executed as soon as you log in to ~/.profile. You might decide to set up an environment variable or aliases for some more type-heavy commands, e.g.:

# add /home/me/bin to the path
export PATH=$PATH:/home/me/bin

# alias for checking apache error log
alias ta='tail -f /home/me/logs/apache/error'