I currently work remotely for a number of organizations which need me to access their servers regularly for maintenance and upgrades. Is it safe for me to add my RSA public SSH key to the .ssh/authorized_keys file to allow me to login much faster/without having to lookup passwords? I operate under the presumption that it'd be impossible to generate the private key from the public one, but am I right in my assumption?

Taking it one step further, would there be any security risk whatsoever in posting the contents of my RSA public key to the internet? I know that if my private key is obtained, I'm in a lot of trouble, but other than that, are there any real possible security threats?


2 Answers 2


Yes, it is impossible to recover the private key from the public key. If it was possible, RSA would be fundamentally broken, and this would be major news (breaking RSA would not only break a lot of Internet communication security, but also allow all kinds of banking fraud, amongst others).

Logging in with a public key instead of a password in fact tends to increase security. If your password isn't strong enough, it can be brute-forced by an attacker with sufficient bandwidth. If the attacker doesn't have a copy of your private key file, the RSA key effectively cannot be brute-forced (a 1024-bit key is equivalent to something like a 160-character password made of random case-sensitive letters and digits). Someone who watches over your shoulder might be able to see your password and your key passphrase, but with a key they'd also need to get the key.

Private keys aren't always more secure than passwords. If the attacker obtains a copy of your private key files (for example by stealing your laptop or your backup media), she can try to brute-force the passphrase, and she can do it at high speed since you have no way to limit the rate (unlike password guesses that need to be made online). If your passphrase is good enough and you notice the theft immediately, you'll still have time to revoke the key.

A public key introduces an element of privacy exposure: if someone knows that you've used the same public key to log into A and to log into B, they know the same person logged into A and B. Merely possessing the public key makes you a suspect that you also have the private key, so you lose some anonimity. But that's usually minor, especially if you're just storing the key in ~/.ssh where only system administrators (who also know what IP address you logged in from) can see it.

These security considerations aside, a private key has many practical advantages. You don't need to type your password so often, and in particular can run automated scripts that don't prompt you once you've entered your key in ssh-agent or the like. You don't need to type your password so often, so you can afford to make it higher-entropy (longer, harder to type). You don't need to type your password so often, so there's less risk that it'll be snooped by a human observer or camera.

  • @NaftuliTzviKay Actually there is something that should be considered here that is an overlooked. In order to use your public key, the system you're shelling in from has to have access to your private key. That's fine. If that private key is stored on that system, it is vulnerable, and the remote system becomes vulnerable. Two things help with this, encrypted home folders, and a password on your key. Therefore, to achieve the full increase in security afforded by PKI, you will lose some efficiency. You, or your organization, needs to do a risk analysis to determine where to draw the line.
    – Jeter-work
    Commented Sep 30, 2016 at 11:37

Gilles' answer is generally good, except

...especially if you're just storing the key in ~/.ssh where only system administrators (who also know what IP address you logged in from) can see it.

Your ssh keys in ~/.ssh can also be read by any software running under your own account. Which is probably most of the software you run. So you must trust that software and those who wrote it.

  • 4
    You should always use encrypted SSH keys for this reason Commented Nov 1, 2016 at 21:32

You must log in to answer this question.

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