Assume a machine with id_rsa and id_rsa.pub.

The machine has to authenticate to multiple services via keypair.

The first service for example is password-less ssh access to another machine by copying the public key to the other server's authorized_keys file.

Now the same machine should authenticate via ssh keys to a second service, like github for example.

Is there any security benefit to create another keypair only for github, and adopting the mentality of a a different keypair per service, or can I just use the same public key everywhere? I guess the question boils down to how much potential damage am I exposing myself to if I use the same keypair for multiple services?

In the latter, if one private key gets compromised it would damage that service alone. But in the former, if that private key gets compromised, I would be exposed to damage from a lot more services at once. So it just seems to me that multiple keypairs is the way to go, but does the administrative overhead justify the added security?

Think of key pairs as an administrative range of systems and data that access is granted too.

If an attacker gets access to one what does he/she gain access to across everywhere this key pair is used?

If you used different key pairs for different services how would this limit the attacker's access?

Finally as an example, if you used one key-pair to move public images for a handful of web servers to and from a public image providing service (let's call it GifHub) and another key-pair for moving credit card data to a separate set of systems hosted by your credit card processor (ignore PCI for a moment). Can you think of any reason why you wouldn't want to give your public image providing service access to your credit card processing database? In this hopefully fictitious example, you might notice that one key-pair is protecting data that is public whereas the other key-pair is protecting credit cards. The reason you don't want to use the same key-pair for both is if someone attacks your image moving application you don't want them to be able to have access your credit-card database. Hence having multiple key-pairs provides a level of defense in depth which is something you want. So using separate key pairs for each service is generally wise.

Note: There are a LOT of other reasons you would want to use different key pairs for different applications or even data moving in different directions. It would take too long to cover all the issues here but yes there is a security benefit and it comes in the form of defense in depth.

Using separate key pairs is only useful if the private keys have different access restrictions.

For example, users John and Mary on a particular server should have different keypairs. If John is compromised, Mary can still be safe.

However, it makes little sense for John to have a couple of private keys in his .ssh directory. If he gets compromised, all of his private keys are exposed. Then it does not matter if he has one or several private keys.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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