BlogComparison

YubiKey vs push MFA for SSH: should you use a YubiKey for SSH, push or codes?

10 min read

YubiKey vs push MFA for SSH is a real choice, and neither is wrong. A YubiKey for SSH holds a FIDO2 key that never leaves the hardware, and a FIDO2 security key is the only one of the three options here that is phishing-resistant. Push MFA through PAM asks for a tap on a phone after the SSH key, and also covers sudo, keeps working offline with codes, and logs every sign-in across a fleet. TOTP codes through the Google Authenticator PAM module are the simplest of all.

This guide compares the three on what an administrator actually has to decide: what the client and server need, what it costs per person, what happens when a key or phone is lost, and when to use two of them together.

YubiKey vs push MFA for SSH: a YubiKey for SSH signs with an ed25519-sk key after a touch, while push MFA through PAM asks the user to tap the matching number on their phone

The short answer

If everyone who logs in can carry a hardware key, and every SSH client they use supports FIDO keys, a YubiKey (or any FIDO2 security key) is the strongest second factor for SSH. If you also want sudo gated, a log of who signed in where, and a way in when a machine is offline, push MFA through PAM covers what a key alone does not. TOTP codes are the low-effort option for a few servers with no account anywhere.

They are not exclusive. sshd can require a security-key-backed SSH key and then a push, which is covered at the end.

How a YubiKey for SSH works: ed25519-sk and ecdsa-sk keys

OpenSSH 8.2, released in February 2020, added support for FIDO/U2F hardware authenticators through two new key types, ecdsa-sk and ed25519-sk. You create one with ssh-keygen while the key is plugged in, and then use it like any other SSH key: its public half goes in authorized_keys as usual.

The difference is where the secret lives. OpenSSH’s release notes say the private key file “should be useless to an attacker who does not have access to the physical token”, because the per-device key on the token “cannot be exported from the token hardware”. The token has to be attached each time the key is used, and by default sshd wants proof of a touch on it for every signature.

ssh-keygen -t ed25519-sk -O resident -O verify-required
# older YubiKey firmware: ssh-keygen -t ecdsa-sk ...
  • Yubico says ed25519-sk needs YubiKey firmware 5.2.3 or newer, and that ecdsa-sk works on all FIDO2 YubiKeys.
  • It is still public key authentication. It protects key-based SSH logins and nothing else: not sudo, not su, not a password login.

What the client and server need

Both ends need a recent enough OpenSSH. The sk key types arrived in OpenSSH 8.2, so the server’s sshd must be at least that to accept them. Yubico lists OpenSSH 8.2 or newer for the client, 8.3 to download resident keys with ssh-keygen -K, and 8.4 for verify-required.

The client is where most of the friction is. OpenSSH talks to the key through a middleware library that needs libfido2, and Yubico notes that Apple’s bundled macOS OpenSSH is not built with it, so macOS users install OpenSSH from Homebrew, and that the Windows OpenSSH client gained FIDO support in version 8.9. Check every laptop, CI runner and jump host that will use the key.

Resident keys, touch and PIN

A normal sk key is in two parts: a key handle in the private key file on disk, and the secret on the token. A resident (discoverable) key, created with -O resident, stores the handle on the token too, so ssh-keygen -K or ssh-add -K can recover it on a new computer. OpenSSH warns that this makes a stolen token more useful to an attacker, and says to set a PIN on the token before creating any resident keys.

Two options decide what each login asks for. verify-required makes the key demand user verification, which OpenSSH currently supports as a PIN, for every signature; sshd can insist on it in authorized_keys. no-touch-required does the opposite and drops the touch, which sshd refuses unless authorized_keys allows it.

When a YubiKey is lost

Nothing on the server can bring a lost key back. Yubico’s advice is to consider a backup key, which in practice means registering two keys per person, both in authorized_keys, and keeping one somewhere safe. When a key is lost, remove its line from authorized_keys on every server it could reach.

That makes the hardware cost per person, not per server. On Yubico’s own store on 2 December 2026, the FIDO-only Security Key NFC was $29 and the YubiKey 5C NFC was $58, so two keys each comes to between $58 and $116 per person, once.

Push MFA through PAM for SSH and sudo

Push MFA sits in PAM rather than in the key. With U2 Secured, sshd checks the SSH key first, and then the pam_u2auth module sends a push to the U2 Secured Authenticator app. The terminal shows a number, the phone shows three, and the person taps the one that matches. A wrong number or Deny ends the login. Because it is a prompt, it asks nothing of the SSH client beyond showing it, and scp, sftp and tunnels go through the same check.

Being in PAM is what lets it reach further than a key can. The same package gates sudo and su, and on the Ubuntu desktop the login and lock screens.

# /etc/ssh/sshd_config.d/u2auth.conf
UsePAM yes
KbdInteractiveAuthentication yes
Match Group u2mfa
    AuthenticationMethods publickey,keyboard-interactive
  • Offline: if the machine cannot reach U2 Secured, it asks for a code from the same app or a single-use backup code, checked on the machine itself.
  • One app for the fleet: each person pairs their phone once, and every machine can send them a push. The push names the machine.
  • A sign-in log: registered machines report every sign-in to the developer portal, including the ones they decided offline, and the portal shows a gap if a report went missing.
  • A lost phone: u2auth-admin reset --unpair removes the pairing for the whole fleet, then enroll pairs the new phone. Backup codes get the person in meanwhile.

TOTP with the Google Authenticator PAM module

The google-authenticator-libpam module asks for a six-digit code from any authenticator app. Each user runs the google-authenticator command, which stores their secret in ~/.google_authenticator on that machine, and can generate up to 10 emergency codes. By default it asks for the code after the normal Unix password.

It needs no account, no network and no hardware, which makes it a reasonable choice for a few servers. What it does not give you is a push, a central list of who signed in where, or one secret for the whole fleet: each server has its own unless you copy them across.

Only the FIDO2 security key is phishing-resistant

A FIDO2 security key is phishing-resistant for SSH. The secret never leaves the hardware, and in SSH public key authentication the signature covers the identifier of that one connection, so a fake server cannot pass it on to the real one.

Push approvals with number matching and TOTP codes are not phishing-resistant in the way a FIDO2 security key is. A person can be led to a fake server that relays the prompt in real time. Number matching makes an unexpected push much harder to approve by reflex, and checking host keys helps, but if that is the threat you are designing against, use a security key.

Side by side

The three, on the points administrators ask about most.

  • What it protects. Security key: key-based SSH logins. Push through PAM: SSH, sudo and su, and Ubuntu desktop logins. TOTP through PAM: whatever PAM services you add it to.
  • Client needs. Security key: OpenSSH with FIDO support on every client, and the key plugged in. Push and TOTP: any SSH client that shows a prompt, and the person’s phone.
  • Server needs. Security key: OpenSSH 8.2 or newer. Push: the u2auth package on Ubuntu 22.04 or 24.04 or Debian 12 and 13. TOTP: the PAM module.
  • Offline. Security key: works with no network at all. Push: falls back to codes checked on the machine. TOTP: works with no network at all.
  • Sign-in log. Security key and TOTP: sshd’s own logs on each server. Push: one log for the fleet in the developer portal.
  • Cost. Security key: hardware for each person, ideally two keys. Push: the free Developer plan has 1,000 active users and 100 push approvals a month, and Growth is $99 a month for the account, not per user. TOTP: free.
  • Lost factor. Security key: the backup key, then remove the lost one everywhere. Push: backup codes, then unpair and re-enrol once for the fleet. TOTP: emergency codes, then a new secret on each server.

When each one fits

A fair rule of thumb:

  • A YubiKey for SSH fits a small team of engineers who all work from machines they control, where phishing resistance matters most and handing out hardware is easy.
  • Push MFA through PAM fits a fleet where sudo matters as much as SSH, where people log in from many kinds of client, where you want one sign-in log, or where shipping keys to everyone is not practical.
  • TOTP fits a handful of servers, a home lab or a single admin who wants no account and no hardware.

Combine them: a security key and a push

The two strongest options stack. sshd’s AuthenticationMethods publickey,keyboard-interactive (the U2 Secured setup above) requires the public key first and the PAM prompt second, and the public key can be an ed25519-sk or ecdsa-sk key on a YubiKey like any other. The result asks for the hardware key, then a tap on the phone, and sudo stays behind the push.

You can also mix by group: people who carry keys use sk keys, everyone else uses an ordinary key plus a push, and every SSH login still needs two factors.

Common questions

Which OpenSSH version do I need for a YubiKey?
OpenSSH 8.2 or newer for the sk key types, on both client and server. Yubico lists 8.3 for downloading resident keys with ssh-keygen -K and 8.4 for verify-required. The client must also be built with FIDO support.
Is ed25519-sk or ecdsa-sk better?
Use ed25519-sk if the key supports it. Yubico says it needs YubiKey firmware 5.2.3 or newer, and that ecdsa-sk works on all FIDO2 YubiKeys.
Can a YubiKey protect sudo on a server?
Not through the SSH key: an sk key only covers SSH public key authentication. Yubico’s pam-u2f module brings FIDO2 keys to PAM services, but it is set up per service and the key has to reach the machine doing the check. A push through PAM gates sudo on the server directly.
Is push MFA as phishing-resistant as a security key?
No. Number matching makes a push much harder to approve by mistake, but a prompt can be relayed by a fake server. Only a FIDO2 security key is phishing-resistant here.
Can I use a YubiKey and push MFA together?
Yes. Require publickey,keyboard-interactive in sshd and give people sk keys: the key is checked first and the push second.
What does push MFA for SSH cost?
The free Developer plan covers it: 1 app, up to 1,000 active users and 100 push approvals a month. Codes from the app and backup codes are never metered. Every login is one push, and if the monthly pushes run out, logins fall back to codes.

Sources

OpenSSH, Yubico and Google statements are from their own pages, read on the date shown. Prices change; check Yubico’s store for the current figures. U2 Secured is not affiliated with or endorsed by Yubico or Google.

Put a push in front of SSH and sudo

Number matching, offline codes and one sign-in log for the fleet. Use it on its own or after a security key. The Developer plan is free.