Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Many articles suggest that using public key authentication is more secure than using a password. References: and

I beg to differ.

The problem with public key authentication is that it converts the authentication mode from "something you know" to "something you have in your home folder".

Consider the attack propagation. If a single machine is compromised, you are better off containing the attack within the same machine when using password based authentication rather than a public key - using which every machine is compromised.

My opinion is if scripts are not used in the server - that store the password, having password authentication and account lockout for bruteforce is much stronger than public key.

When scripts are present - 1. Ensure that scripts run as least privileged user as possible and use public key authentication for the scripts to access other machines. 2. It scripts require root privileges to run, still use the same unprivileged account and use a local executable with suid (accessible only to the script) to run the privileged command.

Any thoughts?

share|improve this question

closed as not constructive by Daniel Andersson, Michael Hampton, Mokubai, ChrisF, Paul Feb 10 '13 at 9:02

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

You can have multiple keys just like multiple passwords. It's actually easier, since you don't have to remember the keys or use a special tool to manage them. Keys are more difficult to brute-force than the name of your cat (people tend to use crap passwords). Also, you can restrict what you can do with a key on a particular server, e.g. not open a shell. – Daniel Beck Feb 9 '13 at 16:31
1. If you wish, you can protect your private keys with a passphrase. 2. If I manage to compromise one machine, I can install a key logger. – Dennis Feb 9 '13 at 16:34
Agree with Daniel and Dennis. However using passphrase doesnt help the scripts - since they need to be hard coded again in the scripts. Keylogger takes time to retrieve passwords. It is not like a compromise while having public key authentication you have it lets access to other machines almost immediately. Of course each of these methods must have additional security components (e.g. system monitoring, key management software for public key). – zethra Feb 9 '13 at 16:52
I do not like that fact that public key authentication is regarded more secure compared to password - These are two different schools of thought and each one should be used selectively and should be complemented by having additional security components. – zethra Feb 9 '13 at 16:52
You may get better answers to this question at our sister site Information Security. Check their FAQ and search first, as the question may already have been answered. – Michael Hampton Feb 10 '13 at 4:04

Actually, when using PKI you can revoke a cert in the event you learn it's compromised. Windows even forces you to use a password when you export the private key (which does the decryption of anything encrypted w/ the corresponding public key), so when trying to import the key to use, the attacker will need to know the password also. Not to mention a SHA-512 hash is harder to crack than, let's say 'Mike5$ecureP@ssword', for exmaple :-)

share|improve this answer

There are a few reasons its more secure, however to some extent you are comparing apples with oranges. First a few general observations -

  1. Passwords are inherently insecure as they have a (comparatively) limited keyspace, and people are very bad at coming up with truely random passwords.
  2. If a password is used, and any machine where that password is used, it provides a lot of leverage to "brute force" the password as the encrypted version is known.

A public/private key solves these problems as follows:

  1. They use a hugely large keyspace - with a reasonable number of bits and enough randomness it would take until after the end of the universe to reverse the private key from the public key [assuming there is not too much weakness in the one-way algorythm)

  2. Even if a system you have logged into (ie not your own) is compromised your security paradigm is still in tact.

Now the kicker and answer -

You may want to revise your belief that public key authentication "converts the authentication mode from "something you know" to "something you have in your home folder". While you certainly CAN leave off the pass phrase, this is not (in the general case) best practice, and all public/private key systems I am aware of support (and ask for by default) a pass phrase.

Wrapping it up, unless the machine that is compromised is yours, you are more secure with a public/private key login. If the machine that is compromised is yours, a password does not help you that much as it can be sniffed on the way through !!!

share|improve this answer

There are a few reasons:

  • Keys can be easily restricted to certain IP addresses. They can also be restricted to executing certain commands, which is useful for scripts (as you noted, scripts require the private key to be stored unencrypted on your hard drive; however, you can hugely reduce the potential danger from that key). You can also use multiple keys for one account, allowing each script to have its own key, which is restricted like this. If you combine this with a passphrase for your key, generic login credentials aren't stored anywhere unencrypted. This is far more secure than putting your password in plaintext, because that allows someone to do anything with your account.
  • Passwords are sent to the remote server; private keys are not. This matters if the remote server is compromised (or if someone else poses as the remote server): they could modify sshd to steal a password, but they can't steal your private key.
  • If a private key is compromised, it's really easy to change it. Changing a password to a truly secure password requires you to memorize yet another password.
  • Private keys have much more entropy than passwords. A randomly-generated 20 character password has nothing on a 2048-bit key pair. This makes brute-forcing much harder than for passwords.
  • If you store your key with a passphrase, an attacker has to get two pieces of info to get your credentials: the key and the passphrase. If someone watches you type the passphrase, they still don't have the key. If someone steals the key, they still don't have the passphrase. If you're careful about where you put your private key, stealing the file is no easy task (for example, if it lives on a flash drive that you carry on you, a remote attacker can't get it).
share|improve this answer

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