A rantbox

Fri 24 August 2012

Doing nice things with your SSH config file

Posted by Michiel Scholten in posts   

If you are running a unix-like machine, like a Linux workstation, or BSD or Apple Mac, you might be acquainted with the ~/.ssh directory. SSH stores known hosts in their, as well as your public and private SSH keys and more important stuff.

The contents of a ~/.ssh/config look something like:

Host homeserv
    HostName home.mydomain.net
    Port 22
    User michiel

    # Routers, so I config them from on the road
    LocalForward localhost:8001
    LocalForward localhost:8002

    LocalForward localhost:

    # SickBeard
    LocalForward localhost:8081 localhost:8081

Host dev
    HostName dev.corp.net
    Port 22
    User mscholten

Of course you can add as many 'Host' configs as you like.

You can now use these configs from your terminal: ssh dev instead of ssh mscholten@dev.corp.net (or those long lines with port forwards you tended to create an alias for in ~/.bash_aliases).

Bonus: if you are running gnome-shell on your machine, you can install the SSH search provider extension, so you can directly launch a terminal with all settings in place from the overview page. Productivity boon in my not-so-humble opinion ;)

For more information, see Advanced SSH configuration and tunneling: We don't need no stinking VPN software.

Also, if you want do some VPN-like stuff, you really need to check out Never again be thwarted by restrictive "guest" wifi (e.g. on buses or airplanes). The sshuttle proxy they use is really nifty.