2

Is it possible to get hold of an RSA private key (pem file) simply by having (root) access to a server that authorizes ssh access using that that private key. For example, can the entries in .ssh/authorized_keys be used to generated the RSA private keys for which they are associated with.

The reason I ask is because I need to disable ssh access to a server with a particular key file. I've edited the authorized_keys file manually and removed the entry associated with that key. That worked and ssh access is no longer possible with that key file, but before I did that, I had created a new private key for ssh access.

I'm concerned that someone with that disabled key file may have been able to acquire the new RSA private key before I was able to delete the old one.

Is that possible?

  • Cross-posted on Super User. – JakeGould Sep 9 '15 at 14:34
  • Hi RTF - welcome. Please do not cross post to multiple stack exchange sites. This probably is the right place, but the mods over on SU could have easily migrated it for you rather than have to clean up. – Rory Alsop Sep 9 '15 at 16:39
  • OK, I'll stick to one site from now on – RTF Sep 9 '15 at 17:01
7

When authenticating using a key, the actual private key is never transmitted; only some data supplied by the server is signed using the key to prove you have it. SSH'ing to a rogue server using keys doesn't compromise the key forever. It may allow the attacker to use the key while you're connected if you have SSH agent forwarding configured, but once you disconnect the attacker can't use the key anymore.

Note that if you suspect the machine to be compromised, you still should follow the standard procedure just to be safe. Not because of your new key (it's safe) but because of other sensitive data the server may be handling. The fact that you deleted the old key from .ssh/authorized_keys doesn't mean you're not already running a compromised sshd with the attacker's key hardcoded in it.

1

For example, can the entries in .ssh/authorized_keys be used to generated the RSA private keys for which they are associated with?

What does .ssh/authorized_keys file contain? It contains the public key uploaded by the client (you) to the server. It is ssociated with its paired key, but the private key can NOT be derived from the public key. And that is is a key requirement for the public key paradigm to work.

Is that possible?

Yes, it is possible not only before deleting the old one but also after that because an attacker may manage to get root access to the servers and modify the keyutils-libs package.

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.