3

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...

1
  • I just store my keys in separate files. Apr 24, 2013 at 2:36

1 Answer 1

8

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 [email protected]

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

You must log in to answer this question.

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