Skip to content

Instantly share code, notes, and snippets.

@samrocketman
Created April 2, 2014 20:13
Show Gist options
  • Save samrocketman/9942160 to your computer and use it in GitHub Desktop.
Save samrocketman/9942160 to your computer and use it in GitHub Desktop.
Aliasing hosts using ssh `config`.

In ~/.ssh/config you can specify host aliases. For example, let's say you have two different keys you want to use for the same user living on the same host. You would do that in the following manner... (excerpt from ~/.ssh/config)

Host localhost
  User git
  IdentityFile /home/systems/.ssh/id_rsa
Host myaliashost
  HostName localhost
  User git
  IdentityFile /home/systems/.ssh/another_id_rsa

You can connect to the git user living on localhost using either key with the following ssh commands....

  • id_rsa - command ssh git@localhost
  • another_id_rsa - ssh git@myaliashost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment