Fullybaked-logo

fullybaked | davebaker

I'm a developer living in the UK and when I'm not spending time with my wife and our 2 wonderful little boys, I love hacking around with code

I'm passionate about technology, web development, gaming and fencing

20 August 2013

Setting up SSH aliases

SSH Config Files

SSH itself provides the answer to my predicament via the configuration file.

In your ~/.ssh directory you can create a config file and store aliases to lots of different SSH connections, each with their own settings. This makes it much easier to connect to servers you use regularly.

For example:

Host client1
    HostName client1.domain.tld
    User foobar
    IdentityFile ~/.ssh/id_rsa
    FowardAgent yes

That's a simple alias block for a connection to a fictious host. The alias is on the first line and the settings indented underneath. Although I should note that the indent isn't required, I just prefer it for readability.

Having set this up, you can now simple type the following on the terminal prompt to connect to the host as user foobar with the specified ssh private key file.

ssh client1

You can set up as many host blocks in the config file as you like and they can have different settings for each one. You could even resort to different private keys for each one if the requirement arose.