14

I hope this is an appropriate place to ask this question. I've been thinking recently about public and private keys, and I'm wondering what the best practices are related to management of my own personal private keys. Specifically, if I regularly use three different computers (personal desktop, work desktop, laptop), along with others with more occasional use, what is the best way to use private keys?

Currently I generate a new key pair on each computer I'm using, then end up adding them to authorized_keys as I need them. Is this the best way to go, or should I be using a single key pair and copying it to all of the computers I use? I guess the question is, should my key pair be used to identify "me", or to identify "me at X computer"?

  • What are we talking about here? What will the keys be used for? Based on your brief reference to authorized_keys, I would assume SSH. Can you please confirm and/or add proper information/tags to your question. – MEMark Oct 12 '15 at 10:48
11

The question is a bit confusing. As I understand it, you're asking about logging in to a server, via SSH set up with PubKeyAuthentication, from any of your three machines.

You should generate one pair of keys for each machine. In this way if one private key gets compromised you don't have to regenerate a key pair on all three machines you login from. In fact, you want to identify yourself (to the server) as "you at computer X".

If you were using PGP, then you should be using an unique key pair to identify yourself (to other PGP users) as "you".

  • What about using the same password for all keys? Assuming they are long enough to make a brute force attack on them unfeasible? Just a curiosity, because I use one key for each machine but all of them use the same password...after all I am human – Freedo Oct 16 '15 at 21:52
  • 1
    You can use the same password. In fact it is even common to have passwordless SSH keys to log in from your trusted machine to a remote server. – dr01 Oct 17 '15 at 12:45
3

Each keypair represents an identity. Sometimes it can be useful to have a different identity on each machine you use, but somethimes it can be useful to share an identity between devices.

When you have a separate key for each device, then:

  • Your communication partners need to have the public keys for all your devices and need a verification that it's you (you can provide the latter by signing the keys of all devices with the keys of all other devices). This becomes quite cumbersome when you ever buy a new device.
  • Your communication partners know from which device you send a message, which reduces your privacy.

When you use the keys only for private purposes, for example for logging into your own server, then having a separate key for each device has the advantage that should one key get compromised, you only need to revoke that key and don't have to replace the key on every single device you own. But the cost for this is higher management overhead: To add a new device, you need to log in with an old device to add the new public key. With a shared key, you just need to copy the key to the new device.

1

Is this the best way to go, or should I be using a single key pair and copying it to all of the computers I use?

As @dr01 highlighted the risks, you should be using a single key per computer.

should my key pair be used to identify "me", or to identify "me at X computer"?

Any password or key-based authentication system only identifies the knowledge of the secret or key and not the user.

The problem with using a password for authentication is that it doesn't prove the person logging in is you. All it proves is that they know your password (http://www.pcmag.com/article2/0,2817,2428440,00.asp).

So a key never identifies you, it only identifies if a user (you at computer X or anyone at computer Y) has the key.

1

Consider also the idea of using a hardware device. A YubiKey NEO can store a GPG key and gpg-agent can use that to authenticate it to any server exactly like a regular ~/identity file.

There's a tutorial for using gpgkey2ssh and gpg-agent to set this up.

-3

You don't need to generate a new key pair for each machine. You just need to import the current keys on all machines.

If you generate three new key pairs, then your contacts will be confused to choose.

  • 2
    The OP is talking about SSH, not PGP. – dr01 Oct 11 '15 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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