If you're like me, and you often have to log in to a number of Linux servers on any given day, with different usernames and even different SSH keys, then you're probably also frustrated with having to remember which one goes where, and which command line argument to use.
Enter the SSH client config file.
SSH Client Configuration
With some once-off entries in your local config file, you can forget about all the options and just use rememberable hosts you configured. Let's have a look at some simple examples:
Host pacific HostName my-server.somewhere-in-the-pacific.on-an-island.example.com
Then all you need to do is ssh like so:
$ ssh pacific
What if you use a different username to log in? Simple, specify it too:
Host pacific HostName my-server.somewhere-in-the-pacific.on-an-island.example.com User this-really-horrible-long-username
Not all servers use the same SSH key pair. Sometimes you need to specify which private key to use. You can use the -i option when logging in, or you can put it in the config file.
Host pacific HostName my-server.somewhere-in-the-pacific.on-an-island.example.com User this-really-horrible-long-username Identity /home/user/.ssh/my-other-key-file
The Config File
At this stage I'm sure you're chomping at the bit to implement this, so let's get on with the details.
Simply create a config file in your ~/.ssh directory:
$ touch ~/.ssh/config
Now edit it with your favourite editor, vi.
Using multiple hosts is really easy. Just add a blank line and then add your next Host block.
Host m1 HostName m1.example.com Host m2 HostName m2.example.com
[ Image Credit: Networking Switch by felixtriller ]