SSH Config File for Easier Logins

Using SSH is relatively straightforward and pretty easy. Simply enter something like the following into Terminal:

$ssh user@computer.ip.address

If you don’t already utilize security keys, you’ll be prompted for the password associated with the user that you’re trying to login as. Voila, you’re in and commanding a computer/server remotely.

Despite this simplicity, if you need to access multiple computers/servers and those computers/servers don’t have nice, easy-to-remember domain names, then you’re left with the task of remembering IP addresses for all the different computers/servers. Of course, you can write these down somewhere for future reference, but it would be much nicer if SSH could remember this info for you. As it turns out, SSH can store that info for you! All you have to do is create a config file with the necessary info.

First, on your client computer (i.e. the computer you’ll be using to connect to the remote computer/server), use Terminal to change to the hidden SSH directory:

$cd ~/.ssh

This can also be done via the graphical user interface (GUI) of your computer, if it’s easier. You’ll just have to enable viewing of hidden files/folders. To do so, while you are in a file browser window, go to the “Edit” menu at the top of your screen, select “Preferences” and then check to box to “Show hidden and backup files.” Now you’ll be able to see the “.ssh” folder.

Once there, create a file called “config”. You can do this in a variety of ways. I’ve used the “touch” command in Terminal:

$touch config

Now, we need to add the needed text to this config file. I’ve just used a graphical text editor (gedit) by entering the following in Terminal:

$gksudo gedit config

In the file, I’ve entered the minimally necessary info to accomplish what I want (which is to be able to connect to remote computers/servers without remembering long IP addresses or domain names). For each remote computer/server that you’ll connect to, you’ll have the following text in the config file:

Host easy_to_remember_nickname
HostName IP_address_of_remote_server
User remote_server_login_username
ControlMaster auto
ServerAliveInterval 30
ServerAliveCountMax 3

Now, just save this config file and you’re done! Here’s an example of what the config file might look like with actual info:

Host hotdogs
User MyUserIDforTheServer
ControlMaster auto
ServerAliveInterval 30
ServerAliveCountMax 3

Now, when I decide to use SSH to login to the server located at address, all I have to enter into Terminal is this:

$ssh hotdogs

Additionally, you can append additional entries to this file for each server that you connect to.

Oh, and as for the other info in the config file, I’m not fully certain what they all do (the info for this was provided by a computer guru who works with our lab):

ControlMaster – Don’t know
SererAliveInterval 30 – This is for keeping the connection alive.
ServerAliveCountMax – This is for keeping the connection alive.

Of course, you still have to remember the “pet names” that you give to your servers, but it’s much easier to remember English words that it is to remember a series of digits associated with a particular server.

Leave a Comment