Reference · Keys and encryption
Hardware SSH keys: ed25519-sk on a FIDO2 security key, with a backup key
Make SSH keys that only work with a FIDO2 security key and its PIN: ssh-keygen -t ed25519-sk -O verify-required, resident keys fetched with ssh-keygen -K, sk-ssh-ed25519@openssh.com in PubkeyAcceptedAlgorithms, and a second key on every server.
| Target artifact | SSH key pairs held on a FIDO2 security key (ed25519-sk, or ecdsa-sk on keys without Ed25519), their sk-ssh-ed25519@openssh.com lines in ~/.ssh/authorized_keys, and the server settings PubkeyAcceptedAlgorithms and PubkeyAuthOptions. |
|---|---|
| Default behaviour | ssh-keygen -t ed25519-sk makes a non-resident key: the file on disk holds only a key handle, and every signature needs the security key plugged in and touched; a PIN for each use only with -O verify-required. The default PubkeyAcceptedAlgorithms list includes sk-ssh-ed25519@openssh.com; PubkeyAuthOptions is none. |
| Safe state | Two security keys, each with a FIDO2 PIN and its own key pair made with -O verify-required, both listed in authorized_keys; sshd -T lists sk-ssh-ed25519@openssh.com; every sign-in asks for the PIN and a touch. |
| Check on Linux | sudo sshd -T | grep -Ei '^(pubkeyacceptedalgorithms|pubkeyauthoptions) ' |
| Check for both keys | ssh-keygen -l -f ~/.ssh/authorized_keys |
| Check on Windows | ssh -V in PowerShell shows OpenSSH for Windows 8.9 or later |
| Check on macOS | which ssh-keygen shows Homebrew's copy, under /opt/homebrew/bin or /usr/local/bin |
| Fix on your computer | ssh-keygen -t ed25519-sk -O verify-required -C "key-1", once with each security key |
| Fix on Linux | add both public keys to ~/.ssh/authorized_keys; to make the server require the PIN, put PubkeyAuthOptions verify-required in /etc/ssh/sshd_config.d/00-hardening.conf, then run sudo sshd -t and sudo systemctl restart ssh |
Before you start
- Set a FIDO2 PIN on each security key; Guide 6 shows how on a YubiKey. ssh-keygen's manual says not every FIDO authenticator supports
-O verify-required, and that a PIN is the only verification it uses. - Check the OpenSSH version, with
ssh -V, on each computer you sign in from and on the server:
| Release | Date | What it added for security keys |
|---|---|---|
| OpenSSH 8.2 | 14 February 2020 | The ecdsa-sk and ed25519-sk key types; resident keys with -O resident; ssh-keygen -K and ssh-add -K to fetch them |
| OpenSSH 8.4 | 27 September 2020 | -O verify-required (a PIN for each use) and the verify-required option in authorized_keys; a PIN before a resident key can be read from the key |
| OpenSSH 8.5 | 3 March 2021 | PubkeyAcceptedKeyTypes renamed PubkeyAcceptedAlgorithms; the old name still works |
- Check that the security key supports Ed25519. OpenSSH's 8.2 release notes say every FIDO key must implement
ecdsa-sk, but hardware support fored25519-skis less common. If yours lacks it, use-t ecdsa-skbelow.
Make one key pair on each security key
ssh-keygen's manual says the private key on a security key "cannot be exported from the authenticator hardware", so a backup key cannot be a copy. Make a pair on each key and register both.
Linux, and macOS with Homebrew's OpenSSH
ssh-keygen -t ed25519-sk -O verify-required -C "key-1" -f ~/.ssh/id_ed25519_sk_key1Enter the key's PIN and touch the key when asked. Then plug in the second key:
ssh-keygen -t ed25519-sk -O verify-required -C "key-2" -f ~/.ssh/id_ed25519_sk_key2On macOS, Yubico's documentation says the OpenSSH that comes with macOS is not built with FIDO support, so it cannot make or use -sk keys. Install Homebrew's with brew install openssh, put Homebrew's folder first on your PATH, and confirm with which ssh-keygen.
Windows
Microsoft's Win32-OpenSSH wiki says FIDO keys work in OpenSSH for Windows 8.9.0.0 and later. Its example is ssh-keygen.exe -t ecdsa-sk -f .\id-ecdsa-sk; it does not mention ed25519-sk or -O verify-required. Git for Windows bundles another OpenSSH, so check the built-in one directly:
C:\Windows\System32\OpenSSH\ssh.exe -VYubico notes that the OpenSSH inside WSL2 (Windows Subsystem for Linux) cannot reach a USB security key directly.
Register both keys on the server
While you can still sign in the way you do now:
cat ~/.ssh/id_ed25519_sk_key1.pub ~/.ssh/id_ed25519_sk_key2.pub | ssh USER@SERVER_IP 'cat >> ~/.ssh/authorized_keys'
ssh USER@SERVER_IP 'ssh-keygen -l -f ~/.ssh/authorized_keys'Each security key's line ends in (ED25519-SK), or (ECDSA-SK), after its comment. Test each key with ssh -i ~/.ssh/id_ed25519_sk_key1 USER@SERVER_IP: it should ask for the PIN and a touch.
Check the server
sudo sshd -T | grep -Ei '^(pubkeyacceptedalgorithms|pubkeyauthoptions) 'sshd -T line | Meaning |
|---|---|
pubkeyacceptedalgorithms lists sk-ssh-ed25519@openssh.com | The server accepts ed25519-sk keys, as by default |
pubkeyacceptedalgorithms without it | A configured list leaves it out: these keys are refused |
pubkeyauthoptions none | The default: a touch is required, and a PIN only where the authorized_keys line starts with verify-required |
pubkeyauthoptions verify-required | Every FIDO key must prove its PIN; sshd_config's manual says other key types are not affected |
A key made with -O verify-required makes your computer ask for the PIN; only the server settings above make the server insist on it. For one key, start its line in authorized_keys with verify-required followed by the key.
The list leaves out sk-ssh-ed25519@openssh.com
sudo grep -rinE '^\s*(pubkeyacceptedalgorithms|pubkeyacceptedkeytypes|pubkeyauthoptions)\b' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/Add sk-ssh-ed25519@openssh.com to the list on the line it shows, then run sudo sshd -t and sudo systemctl restart ssh. OpenSSH uses the first value it reads for each setting, so a later PubkeyAcceptedAlgorithms +sk-ssh-ed25519@openssh.com line changes nothing while an earlier list exists.
Warning Ubuntu 22.04 and the SSH agent
Ubuntu's documentation says that on Ubuntu 22.04 LTS the SSH agent does not work with -O verify-required keys, or with servers that set PubkeyAuthOptions verify-required. Use ssh -i instead of ssh-add.
Resident keys for a new computer
A non-resident key needs its key-handle file on each computer. A resident key keeps the handle on the security key, so a new computer can fetch it:
ssh-keygen -t ed25519-sk -O resident -O verify-required -O application=ssh:key1 -C "key-1"cd ~/.ssh
ssh-keygen -Kssh-keygen -Kwrites a public and private file to the current folder for each resident key;ssh-add -Kloads them into the agent instead. With several security keys attached, it reads the first one you touch.-O application=must begin withssh:; a different name for each resident key keeps them apart.- Resident keys made with OpenSSH 8.4 or later need the PIN before they can be read. ssh-keygen's manual warns that storing both parts on the key "increases the likelihood of an attacker being able to use a stolen authenticator device"; the PIN is what protects them.
- On Windows, Microsoft's wiki says to run
ssh-keygen -Kin an elevated administrator terminal.
If a security key is lost
- A second key is registered: sign in with it, delete the lost key's line from
~/.ssh/authorized_keys(its comment shows which), and register a replacement. - It was the only key: nothing can sign in its place, and there is no copy to restore. You need another way in: another key still listed in
authorized_keys, or the console in your hosting provider's web panel. - A reset counts as a loss: Yubico's documentation says
ykman fido resetwipes all FIDO credentials on a YubiKey, including FIDO U2F credentials, and removes the PIN.
Yubico's SSH guide advises considering a backup key, and Token2 recommends using more than one because a key "can be lost or broken".
Which security keys support ed25519-sk
From each maker's own documentation, checked on 13 November 2026:
- Yubico says
ed25519-skon a YubiKey needs firmware 5.2.3 or newer, as do resident keys, and thatecdsa-skworks on all FIDO2 YubiKeys.ykman infoshows the firmware version. - Nitrokey's SSH guide lists the Nitrokey 3 (A, C and Mini models), the Nitrokey Passkey and the Nitrokey FIDO2 as compatible, and makes its keys with
-t ed25519-sk. It names no firmware minimum. - Token2 says its PIN+ series keys support both
ecdsa-skanded25519-sk, and its other keys onlyecdsa-sk.
Related guides and lookups
Sources
- OpenSSH: release notes for 8.2, FIDO/U2F support
- OpenSSH: release notes for 8.4, verify-required
- OpenSSH: release notes for 8.5, PubkeyAcceptedAlgorithms
- Ubuntu manual: ssh-keygen, 24.04
- Ubuntu manual: sshd, authorized_keys options, 24.04
- OpenBSD manual: sshd_config, PubkeyAcceptedAlgorithms and PubkeyAuthOptions
- Ubuntu Server documentation: two factor authentication with U2F/FIDO
- Microsoft Win32-OpenSSH wiki: FIDO/U2F usage
- Yubico: securing SSH authentication with FIDO2 security keys
- Yubico: ykman FIDO commands
- Yubico: ykman base commands, ykman info
- Nitrokey: SSH authentication with FIDO2
- Token2: using Token2 FIDO2 security keys for OpenSSH