OGOPSEC // Dispatch
Secure Linux Authentication: A Practical Guide
Authentication is the act of proving you are who you claim to be. Secure Linux authentication is doing that in a way an attacker cannot easily forge, replay, or steal. Those are different bars, and most Linux systems clear the first without clearing the second. This guide lays out the building blocks in order, so you can see which factor belongs on which gate.
The three classic factors
Every authentication method reduces to one or more of three things:
- Something you know — a password or passphrase.
- Something you have — a hardware key, a smartcard, a phone.
- Something you are — a fingerprint or other biometric.
A password alone is a single "something you know," and it has a fatal property: it can be copied without you noticing. Phishing, reuse across sites, a shoulder-surf, a keylogger — all of them yield a perfect copy. The entire case for stronger authentication rests on adding a factor that cannot be copied at a distance.
PAM: where authentication decisions are made
On Linux, authentication is orchestrated by PAM. Each service — sshd, sudo, the display manager, login — has a file in /etc/pam.d/ describing the stack of checks a login must pass. Understanding this is the difference between hardening one door and hardening all of them.
A simplified stack that requires a password and a hardware key looks like:
Order and control flags (required, requisite, sufficient) matter enormously — a misplaced sufficient can let one passed check short-circuit the rest. Test changes in a separate session you keep open, so a mistake never locks you out.
SSH: keys, not passwords
For remote access, public-key authentication is both more secure and more convenient than passwords. You generate a keypair, place the public half on the server, and keep the private half protected locally.
Then turn off password authentication entirely in /etc/ssh/sshd_config:
This eliminates password guessing against your server in one move. The honest caveat is that the security now rests on the private key file. If it sits unencrypted on a compromised laptop, it is as exposed as a password. That is the problem hardware-bound keys solve.
FIDO2 and hardware-bound credentials
A FIDO2 security key performs the cryptographic proof inside the device. The private key never leaves the hardware, and good keys require a physical touch per use, so remote malware cannot authenticate silently. SSH has supported this natively since OpenSSH 8.2 with the ed25519-sk key type:
Going one step further, a credential can be bound to a specific machine's TPM, so even the hardware token is useless if separated from the computer it was enrolled on. That binding is what turns "something you have" into "something you have, on the machine it belongs to."
Choosing a factor per gate
The last row's weakness is real and worth planning for: the stronger you bind a credential to hardware, the more carefully you must handle loss and recovery. Enroll a backup key and record a recovery path before you lock things down.
Fail closed and keep it verifiable
Two principles separate secure authentication from the appearance of it. First, the system should fail closed: a missing factor denies access rather than silently falling back to a weaker one. Second, you should be able to verify what is actually enforced — read the PAM files, confirm password auth is off, test that pulling the key really denies the session. Security you cannot inspect is security you are taking on faith.
If you would rather not wire PAM, SSH, and TPM binding together by hand, Dire Wolf packages that path: a hardware-anchored credential doing FIDO2 login with its key material bound to the machine's TPM, and fail-closed PAM by default. However you get there, the destination is the same — authentication that rests on something an attacker cannot copy from across the internet, on gates you have actually checked.