How Long Should an SSH Key Passphrase Be? My Rule: Five Random Words
How long should an SSH key passphrase be? My answer is five random words, and I would rather you remember five words than twist one short password into symbols you forget next week.
My old SSH key had no passphrase at all. I made it in a hurry years ago, told myself the laptop disk encryption covered it, and then carried that file around on every machine I owned. The logic felt tidy. It was also wrong, because disk encryption protects a powered off machine, and a running laptop with a logged in session is a different situation entirely. The day I finally put a passphrase on it, using ssh-keygen -p, took about thirty seconds. The years I spent meaning to do it are the embarrassing part.
An SSH passphrase is not a website password. Nobody is rate limiting guesses against it in the usual sense. If someone copies your private key file, they can guess against it offline, as fast as their hardware allows, with nobody watching. That changes the math. A password that survives an online login form, where three wrong tries lock the account, can fall quickly once the attacker holds the file and can try millions of candidates in private. Length is the defense that holds up under that kind of attack, and random words give you length you can actually remember.
How long should an SSH key passphrase be in practice
Here is the arithmetic I use when I decide. One diceware word drawn from a list of 7,776 words carries about 12.9 bits of entropy. Four words give about 52 bits. Five give about 65 bits. Six give about 78 bits. Those numbers assume the words are genuinely random, rolled or generated, not picked because they sound nice together. Picked words are not random words, and a phrase from a book or a lyric is a dictionary entry waiting to be tried.
Guides disagree on the exact floor, and I think that disagreement is honest rather than sloppy. Some say 15 to 20 characters. SSH.com, the company behind the protocol documentation, says at least 80 bits is essential for key passphrases and recommends 128 bits. That stricter view points at six or seven random words, or a long random string. My five word floor is a compromise between that advice and the reality that a passphrase you cannot type reliably is a passphrase you will weaken, write on a sticky note, or remove. Five random words typed from memory beat eight random words you had to paste from a note you lost.
What about the key itself? An Ed25519 key is already strong. The passphrase is not making the cryptography stronger in the mathematical sense. It is putting the private key file behind a second lock, so stealing the file alone is not enough. Think of it the way I should have years ago: the key is the credential, and the passphrase is the safe it lives in. A safe with a three digit combination is barely a safe.
The setup I actually recommend
Generate the key with Ed25519 unless some old system forces RSA, and set the passphrase at creation time when ssh-keygen asks for it. If you already have a key without one, add it now with ssh-keygen -p rather than putting it off until the next key rotation. Store the passphrase in your password manager, not in a text file next to the key, and not in your shell history. Then load the key into ssh-agent so you type the passphrase once per session instead of once per connection. Agent plus passphrase is the combination that makes a long passphrase livable day to day.
One more thing worth saying plainly. Separate keys for separate purposes matter as much as length. A key for a personal server, a key for work, and a key for a code hosting account should not be the same file. If one key is ever exposed, you revoke that one and the others keep working. A single long passphrase on a single key used everywhere is a single point of failure wearing a strong disguise.
So where do I land? Five random words minimum, six for anything that touches production or money, stored in a password manager, typed through ssh-agent. And if you are still deciding between a hardware security key and a passphrase protected key, that is a fair question I have not fully settled for my own setup. Hardware keys remove the passphrase problem entirely, but their recovery story is thinner. For now, the passphrase key is the setup I can explain, back up, and recover from, and that counts for more than theoretical perfection.
Frequently asked questions
How long should an SSH key passphrase be?
Five random diceware words is a sensible floor, giving roughly 65 bits of entropy. Four words, about 52 bits, is defensible for a low value key. Six words, about 78 bits, is what I use for keys that reach production servers.
Is a 16 character password enough for an SSH key?
It depends on how random it is. Sixteen truly random characters are plenty. Sixteen characters built from a name, a year, and a symbol are not, because an attacker guesses patterns, not character counts.
Can I change an SSH key passphrase without making a new key?
Yes. Run ssh-keygen -p and point it at the existing private key file. It re-encrypts the key in place, and the public key stays the same, so nothing on the server side needs to change.
What happens if I forget my SSH key passphrase?
There is no reset. You generate a new key pair, add the new public key wherever the old one was authorized, and remove the old public key. That is annoying by design, and it is why the passphrase belongs in a password manager.
Should an SSH key have a passphrase at all?
Yes, unless the key is for a locked down automation account where a human never types it and the key file itself is protected some other way. An unprotected private key is a login credential sitting in a file, and laptops get stolen.
Related reading: How Many Words Does Your Passphrase Need? Entropy Math, Worked Out · How to Choose a Passphrase for Full Disk Encryption · Is It Safe to Use an Online Password Generator? · Do You Need Both a Passphrase and Two Factor Authentication?