Hardening SSH for Remote Work With FIDO2 Keys and No Password Auth
Bottom line: Replacing password and TOTP SSH auth with FIDO2 resident keys gives you phishing-resistant, hardware-bound authentication, but the operational cost is real: a handful of sshd_config directives, a client-side OpenSSH version floor, and a few failure modes you need to know before you lock yourself out.
I run a small fleet of remote boxes — a couple of VPSes, a home lab behind a WireGuard tunnel, and a jump host that fronts everything else. For years the pattern was: ed25519 key in ~/.ssh, password auth disabled, TOTP as a second factor on the jump host. That worked, but it meant two secrets to protect (the private key file and the TOTP seed), and the TOTP seed inevitably ended up in a backup or a password manager sync that I didn’t fully control. Moving to FIDO2 resident keys collapses that to one physical token plus a PIN, and the private key never leaves the hardware. This is what I changed, what broke, and how I diagnosed it.
What FIDO2 actually buys you over a plain key
A plain ed25519 key is a file. If an attacker gets the file — via a synced dotfiles repo, a compromised laptop backup, a stray scp — they have your key. Passphrase protection helps only until the passphrase is captured or the agent is unlocked. TOTP helps against password reuse but not against a real-time relay: an attacker who can proxy your session can proxy the code too.
A FIDO2 security key generates the private key on the device and never exports it. OpenSSH talks to it over USB HID, the same interface class as a keyboard, so there’s no vendor driver or PKCS#11 middleware in the path. The key types are ecdsa-sk and ed25519-sk (plus their -cert variants). With verify-required, the token demands a PIN per use, which means a stolen key alone is not enough. That’s the phishing-resistant property: the signature is bound to the specific SSH handshake, and the user-presence check is a physical touch you can’t replay.
The trade-off is portability. A resident key lives on the token, and you re-materialize the key files on any machine with ssh-keygen -K. That’s convenient, but it also means the token is now a single point of failure for your access — which is why you enroll two.
Version floors and platform gotchas
The first thing to check is ssh -V on every client you’ll use. FIDO support landed in OpenSSH 8.2 (released 2020-02-14). verify-required for PIN-per-use needs 8.4 or later. On Windows, in-box OpenSSH needs to be 8.9 or later; older builds silently lack the -sk key types. On macOS, the system OpenSSH is built without FIDO support — you need the Homebrew build and it has to come first on PATH.
| Platform | Minimum for ed25519-sk |
Minimum for verify-required |
Notes |
|---|---|---|---|
| Linux (distro OpenSSH) | 8.2 | 8.4 | Check your distro’s package version, not the upstream release date |
| macOS (system) | Not supported | Not supported | Install Homebrew openssh, put it ahead on PATH |
| macOS (Homebrew) | 8.2 | 8.4 | brew install openssh |
| Windows (in-box) | 8.9 | 8.9 | Older builds need Win32-OpenSSH 8.9+ |
| Windows (WSL2) | 8.2 in WSL, plus Windows-side FIDO components | 8.4 | WSL2 bridges to the Windows FIDO stack |
Token firmware matters too. ed25519-sk keys need firmware 5.2.3 or later on a YubiKey 5 series. Storing SSH certificates on the key (via largeBlobs) needs 5.7 or later. If you’re on an older key, ecdsa-sk is the fallback.
Generating and enrolling the key
Generate a resident key with a PIN requirement and a touch requirement. The -O resident flag stores the key on the token so you can re-download it later; -O verify-required forces the PIN.
1 | # Generate a resident, PIN-protected ed25519-sk key |
The application string namespaces the credential so you can keep separate keys for work and personal use on the same token. Enroll the public key on every host, including the jump host, and keep a second token enrolled as a backup before you disable anything else.
To re-materialize the key files on a new machine — the whole point of resident keys — pull them off the token:
1 | # Download resident keys from the token into ~/.ssh |
ssh-keygen -K writes id_ed25519_sk and id_ed25519_sk.pub into the current directory (or ~/.ssh if you run it there). The private key file it writes is a stub that references the token; the actual secret stays on the device.
Hardening sshd_config
The server side is where the security posture actually gets set. The goal: no passwords, no keyboard-interactive fallback that quietly re-enables TOTP, and only the key types you intend to accept. Edit /etc/ssh/sshd_config:
1 | # /etc/ssh/sshd_config |
PubkeyAcceptedAlgorithms is the important line. Without it, a user with an old ed25519 file key can still authenticate. Restricting to the sk- algorithms means the only way in is through a token. On older OpenSSH the directive is spelled PubkeyAcceptedKeyTypes; check man sshd_config on the target.
Validate before you reload, because a typo here locks you out:
1 | sudo sshd -t && sudo systemctl reload sshd |
Keep an existing session open while you test a fresh login in a second terminal. If the new login fails, you still have the old session to revert.
Pitfalls and how to diagnose them
These are the ones I hit, in the order I hit them.
ssh-keygen -t ed25519-sk fails with “device not found” or “key type not supported”. Either the OpenSSH build lacks FIDO support (macOS system build is the usual culprit) or the token firmware is too old for ed25519. Check ssh -V and try -t ecdsa-sk as a fallback.
Authentication hangs after the touch prompt. The ssh-sk-helper binary (new in 8.2) does address-space isolation for the token middleware and has to be installed in the expected path, typically under /usr/libexec or similar. If it’s missing, the client can’t complete the signature. Confirm it exists and is executable.
Permission denied (publickey) even though the key is enrolled. Run the client with -vvv and look for which algorithms the server offered. If PubkeyAcceptedAlgorithms on the server doesn’t include the sk- type you generated, the key is silently skipped. Also check that the public key line in authorized_keys is the sk-ssh-ed25519@openssh.com line, not a stale ssh-ed25519 line from an earlier attempt.
PIN prompt never appears with verify-required. The client OpenSSH is older than 8.4. Upgrade the client; the server can’t force the PIN behavior on a client that doesn’t understand it.
Resident key download returns nothing. The application string on ssh-keygen -K must match the one used at generation. Default is ssh:, which is easy to forget if you customized it.
Locked out after disabling passwords. This is the one that matters. The fix is procedural, not technical: enroll two tokens, keep a root console or out-of-band access path (serial, provider web console, physical keyboard) open during the change, and test the second token before you close the first session. I also keep a break-glass ed25519 key in a sealed offline location and a matching Match User breakglass block that permits it — audited and rotated, but there when the tokens are both in a drawer somewhere.
Operational notes for async remote work
The async-communication angle is underrated. With TOTP, a colleague asking you to “just check the box” means reading a code out of an app and relaying it — which trains people to relay codes. With FIDO2, there’s nothing to relay. The token has to be physically present and touched. That changes the social engineering surface: a request to “share the code” has no answer, because there is no code.
Two habits that paid off. First, document the enrollment procedure in the runbook with the exact ssh-keygen flags, because the -O application string is the thing people forget six months later. Second, rotate the authorized_keys entries when a token is retired — a resident key on a lost token is still a valid credential until you remove its public key from every host. Keep an inventory mapping token serial to authorized_keys entry so revocation is a lookup, not an archaeology project.
FAQ
Does FIDO2 SSH auth work without a PIN?
Yes, if you omit -O verify-required at generation time. The token then only requires a touch. That’s still hardware-bound and phishing-resistant, but a stolen token is usable by whoever holds it, so for remote admin access I’d keep the PIN requirement on.
What happens if I lose the security key?
Nothing, provided you enrolled a second token and kept its public key in authorized_keys. Generate and enroll the backup before you disable password auth. If you didn’t, you fall back to your break-glass key or out-of-band console access.
Can I use the same token for SSH and web logins?
Yes. A FIDO2 key registered for WebAuthn can also hold SSH credentials, and the application string keeps the SSH credential namespaced separately. One token covers both, which is the main practical argument over PIV or PGP setups.
Why does my macOS client say the key type isn’t supported?
The system OpenSSH on macOS is built without FIDO support. Install OpenSSH from Homebrew and make sure it precedes /usr/bin on your PATH, then re-check with ssh -V.
Do I still need TOTP if I’m using FIDO2 keys?
No. Once PasswordAuthentication and KbdInteractiveAuthentication are both off and PubkeyAcceptedAlgorithms is restricted to the sk- types, TOTP has no path to authenticate. Keeping it enabled as a fallback reopens the relay attack surface you just closed.
How do I move my key to a new laptop?
Run ssh-keygen -K on the new machine with the token plugged in, matching the application string you used originally. It downloads the resident key stub into the current directory; move it to ~/.ssh and set permissions to 600.







