For those of you connecting to multiple instances via SSH, setting up a local configuration file can save you the effort of having to keep track of things like: host names, user names, and command line switches. What follows is a quick guide on how to set one up.

First, if the file doesn't exist, create one with: touch ~/.ssh/config. Then, using a text editor, edit the file, e.g.: vi ~/.ssh/config.

The structure of the config file is straightforward. Here's a sample entry:

# geekberg.info web_server_1
Host geekberg
    HostName 159.65.178.169
    User poindexter
    Port 1234

On the first line, we've added an optional comment # with the fully-qualified domain name of the host and a brief description of the same. We separate each entry in our file with a space and a #.

Next, we have an entry for Host, which is the short name we will use to connect to this server.

Then, on the first indented line, we add a HostName entry which can be either the IP address of the server or its fully-qualified domain name. We like to use the former, as there are can be times when DNS resolution is not available.

On the next indented line we have an entry for the user name we will connect to the server with. Then, on the last indented line, there is an entry for the port the SSH service is listening on. If SSH is running on Port 22--which it is by default--you don't even need this line.

Once you've saved your config file, you can SSH in to your server with, e.g.: ssh geekberg.

An additional benefit of utilizing a config file is that it can be used with related secure shell services such as: secure copy (scp) and secure file transfer protocol (sftp). Also, the file is highly customizable.

Cheers.