OGOPSEC Brand Mark
OGOPSECOBSIDIAN GOOSE

OGOPSEC // Dispatch

Disable SSH Password Login (and Why You Should)

By Jamie Folsom ·

If you do one thing to a public-facing Linux server this week, disable SSH password login. Password authentication over SSH is the single most attacked surface on the internet: automated bots spray millions of username-and-password guesses at every reachable port 22, around the clock. Switching to key-only authentication takes that entire attack off the table. This post shows how to do it safely — the emphasis on safely is deliberate, because the one real risk here is locking yourself out.

Why password login is the weak point

A password is a shared secret that gets transmitted on every login and can be guessed offline-fast when exposed. Even a strong password is only one leak, one reused credential, or one convincing phishing page away from being an attacker's. The logs of any server with password auth enabled are a wall of failed attempts — that is not background noise, it is a continuous attack you are currently surviving on the strength of a guess.

Key authentication removes the shared secret. There is nothing to guess over the network and nothing to capture in transit.

Do this first: make sure your key works

Disabling passwords before confirming your key is the classic way to lock yourself out. Order of operations is everything.

On your client, generate a key if you do not have one, then copy it to the server:

ssh-keygen -t ed25519 -C "you@workstation"
ssh-copy-id you@server

Now prove it. Open a new terminal and connect. You should get in without being asked for your account password (a passphrase for the key itself is fine and good):

ssh you@server

Do not proceed until this works reliably. If it does not, fix the key setup first — never disable passwords on a hope.

Disable password authentication

Edit the SSH daemon config. On modern systems, prefer a drop-in file so your change is not overwritten by package updates:

sudo tee /etc/ssh/sshd_config.d/99-hardening.conf 

A subtle gotcha: some distributions ship a default drop-in that re-enables PasswordAuthentication, and the last matching directive can win depending on include order. Confirm the effective setting rather than trusting the file you edited:

sudo sshd -T | grep -i passwordauthentication

It should report passwordauthentication no.

Reload — but keep your lifeline open

Reload the daemon. Crucially, keep your current SSH session open the entire time:

sudo systemctl reload sshd

Now, from a separate terminal, open a fresh connection to confirm key login still works and password login is refused. Only once that new session is solid should you close your original one. If something is wrong, your still-open first session is how you fix it instead of calling the hosting provider's console.

Don't forget the console fallback

Disabling SSH passwords does not disable local console passwords, which is good — it means your out-of-band recovery path (the VPS provider's web console, or a physical keyboard) still works if you ever lose your keys. Know where that console is before you need it. That recovery path is also why key-only SSH is safe to adopt: you are closing the remote door, not bricking the machine.

What disabling password login protects against — and what it doesn't

This change defeats the overwhelming majority of real SSH attacks: credential spraying, brute forcing, and password reuse against your server. It is high-value and low-effort, which is a rare combination.

It does not protect you if your private key is stolen in a usable form, if your client machine is compromised while the key is loaded, or if you leave stale authorized keys in place for people and machines that are long gone. The risk does not disappear — it moves, from the network to the custody of your private key. Protect that key with a passphrase, and for the strongest posture, anchor it to hardware so it cannot be silently copied. A device-bound credential like Dire Wolf keeps the key on a TPM-backed token that will not export it, which is the honest completion of "no more passwords": no password to guess, and no key file to quietly lift.

Disabling SSH passwords is the best ten minutes you can spend on a server. Just spend the first five confirming your key, with your current session still open.