Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I create multiple ssh keys, and rename them to user friendly names so I know which key is for which website etc.

Is this safe?

e.g:

github_id_rsa
github_id_rsa.pub
..
...

How will it know which key to check against when connecting?

On my computer now, when I look at known_hosts, they all seem to have the same key after the name of the host??

share|improve this question
1  
Cross-site duplicate: Best way to use multiple ssh private keys on one client – slhck May 23 '11 at 21:07
    
Also, the known host keys are definitely not the same, just look at the ends of the lines for each host. – slhck May 23 '11 at 21:07
up vote 10 down vote accepted

Yes you can have different ssh keys. There's very good documentation on the GitHub Help site at Help.GitHub - Multiple SSH Keys. Essentially you will be using ssh-add to add the extra keys so that the agent can utilize them. Then you set up the ssh hosts config so that any ssh connections to different domains will be looked up here and the appropriate key will be used. good luck!

share|improve this answer
    
Link no longer works – danwellman Feb 19 '15 at 17:45
1  

You can modify the file ~/.ssh/config to use different identity file for different servers. Edit the ~/.ssh/config in your favorite editor and add an entry that is appropriate for your situation like so:

Host *
IdentityFile ~/.ssh/id_rsa

Host *.github.*
IdentityFile ~/.ssh/github_id.rsa

Host *.someother.com
IdentityFile ~/.ssh/someother_id.rsa

The first part above sets the defaults for all hosts and the other sections overrides what should be used for each of the hosts matching the patterns. If you have a different username for each of the hosts, then you can add a User key followed by the username on the remote to the section.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .