Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've already generated a ssh key pair to connect to a remote machine, and now need to connect to a second/separate machine using the same method.

Should I continue using the same existing key pair (by copying the public key to the new machine)? Or should I create a new key pair and use that for the new machine?

If the latter, how should I do it on my local machine without interfering the existing key pair?

share|improve this question
    
    
@TheCleaner, thanks for linking the other question. However, that question doesn't explain how to generate and use multiple key pairs without interfering each other. Could you shed some light on that aspect? –  Simon Hughes Apr 25 '13 at 22:04
    
Sure: serverfault.com/questions/125672/… –  TheCleaner Apr 25 '13 at 22:06
    
you can use option "-i" to use the second key, man ssh –  Danila Ladner Apr 25 '13 at 22:07

2 Answers 2

up vote 0 down vote accepted

You just need to copy your existing public key to all hosts you want to connect to. Just use ssh-copy-id to setup your public key into the remote host.

$ ssh-copy-id user@machine

By default, ssh-keygen creates the authentication key in ~/.ssh/id_rsa or similar. You can however specify a different file name.

$ ssh-keygen /path/to/new/key

And ask to your ssh client to use this key for authentication.

$ ssh -i /path/to/new/key user@machine
share|improve this answer
    
ah, that makes sense. Thanks! –  Simon Hughes Apr 25 '13 at 22:10

Generally, yes you can re-use SSH keys. I would personally consider what identities you have - e.g. Is the second system used for the same purpose? I have different keys for my work and personal servers for example.

Another question might be what would happen if your SSH keys were to be compromised? How secure would you like your security?

To answer the latter question, you can use an IdentityFile line in your SSH configuration (or specify the -i argument on the CLI) to use a different SSH key.

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.