Simplify SSH connectivity with a config file

Managing a large number of servers can be annoying, but a config file will make it much easier. Here I talk about how a config file can make all the difference.

Creating a config file

In order to SSH into a server, the IP address is required and needs to be specified in the terminal command.

$ SSH user@1.2.3.4

The above format is okay if you are only working on a single server, if you have to work with many servers, then managing all the IP address can quickly get out of hand. The beauty of a config file is that it allows you to map an IP address to your domain name. After the mapping, you can just do the following.

$ SSH mydomain.com

If you don't have this file already, then create it first.

touch ~/.ssh/config

Then copy the following template into the file, don't forget to update the relevant values (e.g. domain, IP and user).

Host yourdomain.com  
HostName 1.2.3.4
User root
IdentityFile ~/.ssh/id_rsa
Buy Me A Coffee