SaferComputing.com

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.

Published
Updated
Last checked
Applies to
OpenSSH 8.2 and later on Linux and on macOS (Homebrew's OpenSSH), OpenSSH for Windows 8.9 and later, FIDO2 security keys
Technical specification
Target artifactSSH 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 behaviourssh-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 stateTwo 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 Linuxsudo sshd -T | grep -Ei '^(pubkeyacceptedalgorithms|pubkeyauthoptions) '
Check for both keysssh-keygen -l -f ~/.ssh/authorized_keys
Check on Windowsssh -V in PowerShell shows OpenSSH for Windows 8.9 or later
Check on macOSwhich ssh-keygen shows Homebrew's copy, under /opt/homebrew/bin or /usr/local/bin
Fix on your computerssh-keygen -t ed25519-sk -O verify-required -C "key-1", once with each security key
Fix on Linuxadd 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

  1. 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.
  2. Check the OpenSSH version, with ssh -V, on each computer you sign in from and on the server:
ReleaseDateWhat it added for security keys
OpenSSH 8.214 February 2020The ecdsa-sk and ed25519-sk key types; resident keys with -O resident; ssh-keygen -K and ssh-add -K to fetch them
OpenSSH 8.427 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.53 March 2021PubkeyAcceptedKeyTypes renamed PubkeyAcceptedAlgorithms; the old name still works
  1. Check that the security key supports Ed25519. OpenSSH's 8.2 release notes say every FIDO key must implement ecdsa-sk, but hardware support for ed25519-sk is less common. If yours lacks it, use -t ecdsa-sk below.

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
Linux or macOS terminal, first security key plugged in
ssh-keygen -t ed25519-sk -O verify-required -C "key-1" -f ~/.ssh/id_ed25519_sk_key1

Enter the key's PIN and touch the key when asked. Then plug in the second key:

Linux or macOS terminal, second security key plugged in
ssh-keygen -t ed25519-sk -O verify-required -C "key-2" -f ~/.ssh/id_ed25519_sk_key2

On 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:

Windows PowerShell
C:\Windows\System32\OpenSSH\ssh.exe -V

Yubico 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:

Linux or macOS terminal
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

Ubuntu, as a user with sudo
sudo sshd -T | grep -Ei '^(pubkeyacceptedalgorithms|pubkeyauthoptions) '
sshd -T lineMeaning
pubkeyacceptedalgorithms lists sk-ssh-ed25519@openssh.comThe server accepts ed25519-sk keys, as by default
pubkeyacceptedalgorithms without itA configured list leaves it out: these keys are refused
pubkeyauthoptions noneThe default: a touch is required, and a PIN only where the authorized_keys line starts with verify-required
pubkeyauthoptions verify-requiredEvery 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
Ubuntu, as a user with sudo
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:

Linux or macOS terminal, security key plugged in
ssh-keygen -t ed25519-sk -O resident -O verify-required -O application=ssh:key1 -C "key-1"
Linux or macOS terminal, on the new computer
cd ~/.ssh
ssh-keygen -K
  • ssh-keygen -K writes a public and private file to the current folder for each resident key; ssh-add -K loads them into the agent instead. With several security keys attached, it reads the first one you touch.
  • -O application= must begin with ssh:; 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 -K in 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 reset wipes 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-sk on a YubiKey needs firmware 5.2.3 or newer, as do resident keys, and that ecdsa-sk works on all FIDO2 YubiKeys. ykman info shows 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-sk and ed25519-sk, and its other keys only ecdsa-sk.

Sources