Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.