Setup an SSH Config File

Apr 5, 2011 - 8 Comments

If you use SSH even somewhat often, it would benefit you to setup a basic SSH config file. If you’re curious why, would you rather type something like this:

ssh -p 6851

Or just type:

ssh name

I know what I’d rather do, so let’s get this working. I’m going to use nano editor because it’s user friendly.

Launch the Terminal and type the following:

nano ~/.ssh/config

You’ll probably have a blank config file and that’s fine, so here’s what we’ll add to it:

host shortcutname
Port 5555
User username

Here’s how this might look:

I keep things indented to make them easier to read but it’s not necessary. Once your server and login info is inputted, hit Control+O to save the file, then Control+X to quit out of nano.

Now you can just type the shorthand to connect to a server, such as ‘ssh osxd’ and the full hostname, port, and username will be included for you.

There are many more possibilities with SSH configs, if you want to check out more options just look at the manual page with “man ssh_config”

Check out some more command line tips while you’re at it.


Related articles:

Posted by: David Mendez in Command Line


» Comments RSS Feed

  1. James says:

    This isn’t working for me. When I type ssh shortcutname I get

    ssh: Could not resolve hostname shortcutname: nodename nor servname provided, or not known

    I followed the instructions and nano reported that it had wrote four lines. Any ideas? Many thanks.

  2. […] Line – April 11th, 2011 – No Comments More fun with SSH! We showed you how to setup SSH config files and use tab completion for SSH aliases, but setting up bash aliases is even easier if you are […]

  3. Nick says:

    Or use LocalForward to forward a port on localhost to a machine on the remote network, for example RDP to a *cough*dos host:

    LocalForward 3389

    rdesktop localhost:3389 will log you in to the *hatsjoe*dos machine on the remote LAN.

    Sorry about the cold, folks.

  4. Nick says:

    If you login to host after host after host to get where you want you might want to add

    EscapeChar !

    or even

    EscapeChar none

    to avoid getting logged out of the first connection when really wanting to stop ‘cu’ or ‘tip’ or ‘ssh’ on the remote machine.

  5. […] Line – April 6th, 2011 – No Comments Yesterday we showed you how to setup a basic SSH Config file, and here’s how to make that even more useful: enable tab completion for those SSH […]

  6. diavolo says:

    why not simply use an alias?

    I regularly type “box” which is an alias to “ssh myuser@ip”

    A port can be added with :port# at the end… this alias survives all reboots.

    I guess it is another way to do it…

  7. Mike says:

    Host 10.1.10.*
    StrictHostKeyChecking no

    quite handy for when you use ssh in a lab with servers that often change (dev/test)

Leave a Reply


Shop on and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks


iPhone / iPad



Shop on Amazon to help support this site