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

So far I've created a separate SSH key for each server I need to login to (for each purpose, to be more accurate). I did it out of a sense of security, just like different passwords to different sites.

Does having multiple SSH keys actually improve security? All of them are used from the same machine, are located in the same ~/.ssh, most even have the same passphrase.

So... should I give up the whole system and just use one SSH key for everything?

[UPDATE 2015-08-05] Github publishes your public key, and your SSH client may send all of your public keys to every server, depending on configuration, thusly, if you are concerned with a 3rd party SSH server knowing your identity when connecting, you should use multiple SSH keys, though in my opinion it is paranoid.

share|improve this question
up vote 18 down vote accepted

SSH keys use public-key cryptography. That means that what you're installing on all those servers is just your public key, which you want the whole world to know. The only actual secret is your private key that you keep locked down on your own machine. So yeah, I'd say you're wasting your time.

share|improve this answer
I think there are valid reasons to have separate keys, and this would not be a waste of time. In the case of a compromised key, the risk with this is reduced. The password should be different for each key, I agree. – jfmessier Mar 18 '10 at 16:19

Ultimately this is up to you. You need to evaluate your threat model. How likely is it that one of your keys is compromised? If one key is compromised, how likely is it that the other keys will be compromised? What are the consequences of your keys being compromised? What is the cost (including time) of managing multiple keys?

Considering factors such as these should help you decide if you really need separate keys. On my personal machines on my local network I usually don't bother with extra overhead in trying to manage multiple keys. However, outside of my network I would use different keys each with a unique passphrase. But that is just my personal opinion.

share|improve this answer
+1 for "evaluating the threat model". This is just the point. – sleske May 17 '10 at 8:45

No it is not a waste of time to use more than one key.

More diversity == less risk.

That statement of Spiff's is incorrect.

The point is the public key grants access to the private key holder and no one else.

The risk to be concerned about here is authentication. A rogue site forwards authentication requests to your agent task. If you use only one key, then even when only one key is loaded in your agent, all sites are open to the rogue.

This has nothing to do with the passphrases, you could have several keys with the same passphrase that would make no difference here. Because it is not the passphrase that is compromised.

The rogue forwards challenges to your agent and can connect to all sites for which you have keys loaded. With different keys, one key loaded -> one site at risk.

I say good for you, you picked other peoples privacy over your own laziness.

P.S. the moral of the story is be wary of agent forwarding

share|improve this answer
Suppose I generate three SSH keys, one for each of three servers I log in to regularly. One day, after I've already logged in to all three (meaning that ssh-agent has cached the passphrases for all three keys), then by your argument, if my ssh-agent becomes compromised, all three log ins are compromised. In such a case, having multiple SSH keys has not protected me. Have I understood you correctly? – sampablokuper Apr 23 '11 at 6:17

I think there is one good use-case for multiple public keys, and that's if you have private keys stored on computers in different areas of trust. So I generally keep one key that is my "work" key, and another that is my "home" key, simply because the private key for my "home" stuff is not stored on my work computer and vice versa.

share|improve this answer
Great answer, if you have different machines with different keys, perfect. If one (or multiple) machines all have the same keys, well, you're not protecting yourself from anything extra vs just having a single key. If one is compromised all the rest on that machine are as well. – xref Feb 2 at 20:53

You must log in to answer this question.

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