I'm certainly not saying this is a "good idea," and I always disable password authentication on SSH servers. However, the question came up when talking to a friend: If your password is as long and random as your private SSH key, is there a security difference with logging in with your long password vs. your private key?

My intuition is that the password is less secure because you need to transmit it "over the wire" for the server to authenticate. Whereas your private key stays on your computer, and you only send a calculation of public_key*private_key to the remote server. But then, the remote server has your public key... so is it any better?

Theoretically, brute forcing a 2048 bit password (with proper entropy) should be exactly as difficult as brute forcing a 2048 bit private key, correct?

marked as duplicate by Matthew, Steve, Xiong Chiamiov, CaffeineAddiction, Xander Feb 23 '17 at 20:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Depending on the hashing method used, the 2048 bit password may only provide 576 bits of usable password - 72 characters in bcrypt... – Matthew Feb 23 '17 at 12:27
  • The transport layer (with all the details about encryption) is established before sending the password, so the password is not sent in plain text – Purefan Feb 23 '17 at 12:29
  • @Purefan But the password is still sent... For example, if you accidentally try to SSH into the wrong machine, the "other" machine now has your password, correct? Does the SSH daemon ever get the "plaintext" version of the password or does it compare a hash? – formicophobia Feb 23 '17 at 15:01
  • Yes – Purefan Feb 23 '17 at 15:03
up vote 6 down vote accepted

Theoretically, brute forcing a 2048 bit password (with proper entropy) should be exactly as difficult as brute forcing a 2048 bit private key, correct?

Not quite. A 2048-bit RSA key only have 112-bit effective entropy (explanation).

An SSH public key is safer than a password because in the case that an attacker manage to take over your server, they would be able to capture your password. If you reuse the same password anywhere, they'd be able to login to those machines with the captured password.

With SSH key, an attacker that compromised your server can't go anywhere else.

There's also a slight advantage that once you kick the intruder out, you won't need to change your SSH key. You couldn't lock out the intruder without changing your password.

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