Skip to content

Instantly share code, notes, and snippets.

@subfuzion
Created February 26, 2014 19:10
Show Gist options
  • Save subfuzion/9236280 to your computer and use it in GitHub Desktop.
Save subfuzion/9236280 to your computer and use it in GitHub Desktop.
ssh notes

Just a basic memory aid.

Create keys

Create a new key using the email address as label

$ ssh-keygen -t rsa -C "name@example.com"

Accept the default name (~/.ssh/id_rsa) or provide another for multiple identities

Using different keys

Force ssh to use a specific private key

ssh -i ~/.ssh/<private-key-file> user@host.com

To automatically select identity file to use per host, add entries to ~/.ssh/config

Host hostname1 hostname1.server.com
  HostName hostname1.server.com
  User root
  IdentityFile ~/.ssh/<private-key-file1>
Host hostname2
  IdentifyFile ~/.ssh/<private-key-file2>

Host - the list of names that can match HostName - the real hostname User - the user to log in as, if you don't want to specify on the command line IdentifyFile - the private key to use

Remember to actually specify a different identity file name when using ssh-keygen

@tom93
Copy link

tom93 commented Jan 28, 2018

There is a typo: IdentifyFile should be IdentityFile (7th letter should be 't'). This happened in two places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment