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

I am trying to add an existing private key (id_rsa file) to my ~/.ssh directory, but see that I already have one. Do I have to replace the existing key, or is there a way to combine them?

I assume there must be a way since it should be possible to have keys to different servers from the same user account...

share|improve this question
    
I just store my keys in separate files. – David Schwartz Apr 24 '13 at 2:36
up vote 5 down vote accepted

There are a few options you can take here. In all options you would store the other key in its own file, /home/user/.ssh/id_rsa for these examples.

1) When you want to use a key other than ~/.ssh/id_rsa specify it with the -i argument ssh -i ~/.ssh/id_rsa.otherkey user@server.example.com

2) If you want to use the key multiple times in your current session, add it to your ssh-agent with ssh-add: ssh-add ~/.ssh/id_rsa.otherkey

3) If you want to set this up more permanently you can specify the keys in ~/.ssh/config along the lines of:

Host shortcut
 HostName server.example.com
 User user
 IdentityFile /home/user/.ssh/id_rsa.otherkey
share|improve this answer

You must log in to answer this question.

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