Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (35 sloc) 1.39 KB
layout title tags published
post
SSH config and Git
linux
ssh
true

I recently streamlined my SSH setup (with the help of Joël Perras).

If you're anything like me, you probably log in and out of a half dozen remote servers (or these days, local virtual machines) on a daily basis. And if you're even more like me, you have trouble remembering all of the various usernames, remote addresses and command line options for things like specifying a non-standard connection port or forwarding local ports to the remote machine. [...] Enter the SSH config file:

# contents of $HOME/.ssh/config
Host dev
    HostName dev.example.com
    Port 22000
    User fooey

This means that I can simply $ ssh dev, and the options will be read from the configuration file. Easy peasy.

For me this means easy remote access to Git repositories on my home server (such as the one for this website) for which I use a custom SSH port. Previously I was forced to use the full URI in order to specify this port:

git clone ssh://<user>@<host>:<port>/<repository>.git

However, with a simple entry to my ~/.ssh/config:

Host <host>
    Port <port>

I can now use the following address, omitting the custom port entirely:

git clone <user>@<host>:<repository>.git