The ssh config file

As everyone knows, ssh is the standard when it comes to remote computer access. But if you are responsible for more than a couple of machines, it's easy to forget little details, such as which non-standard ssh port your testing server is using, or under what home directory your Django app is running.

Enter the ssh config file.

In your ~/.ssh folder there is (or can be, if you create it), a file named config. If it's not there, create one now.

Here's a simple example:

Host myserver
    User shawn

Now, instead of typing this all the time:


you can just type this:

ssh myserver

The hostname can be either the domain name or IP address. You can have as many hosts in your file as you want.

That probably already saves you a bit of typing. Here's a more fleshed-out example of features I'm using in my own config file:

Host myserver
    User shawn
    Port 5555
    localforward 7777 localhost:5901
    GSSAPIAuthentication no


  • This host uses a non-standard port. Not only does this save you from entering the -p argument in your ssh command, but other commands, such as scp, git, and rsync will automatically use this config file. This can be a lifesaver, especially if the program you're using has no way to specify an alternative port.
  • Port forwarding is set up. In this case, the server's port 5901 will be accessible to me from my local machine on port 7777. So if I fire up vncserver on the server, I can use vncviewer localhost:7777 locally to connect to it.
  • The GSSAPIAuthentication is just something I threw in for one server I connect to which would take about 30 seconds to connect me, despite the fact that I was using public-key authentication. A Google search pointed me toward a forum where someone recommended disabling it. It solved my problem.

Comments !