Why did nobody ever tell me about ssh_config?


As someone who uses SSH a lot, I need to remember a bunch of different usernames, identity files and even one non-standard SSH port.

It can sometimes be a bit of a hassle, especially if I need to use a specific identity file or other such, and then need to subsequently remember the pathname to it and all that.

But lo and behold, there’s actually something that can do all of this for you!

Why didn’t anyone ever tell me about ssh’s config file?

Enter .ssh/config

On unixy systems, your personal SSH configuration goes into ~/.ssh/config

By plugging specific things into the file, you can automate most of your SSH experience.

Here’s an example:

Let’s say you often connect to a server like this:

ssh test@example.com -p 1234

What if you just had to say…

ssh example.com

Well, put the following definition into the ssh config file:

Host example.com
    User test
    Port 1234

And now it works just like that. No need to remember which port to use or which user name to use. Just ssh example.com and off you go.

Simple and makes your life a bit easier if you work a lot with SSH.

This is only just scratching the surface of what options are available. The manpage contains a quite handy list of possible options:

man ssh_config