by Martin Monperrus

TL;DR: An SSH server can refuse every key that is not provably generated inside a hardware security key. The proof is the FIDO2 attestation that ssh-keygen already writes at enrollment and that OpenSSH never checks.

Three properties

  1. Hardware-bound key generation. The private key is generated inside the hardware, never imported.
  2. Verifiable non-exportability. Anyone holding the public key can check, with a cryptographic proof, that the private key cannot leave the hardware.
  3. Auditable execution. The code that generates and uses the key can be inspected.

For an SSH server, these properties turn every login into evidence of physical possession. If the key provably exists only inside one device, then whoever logs in holds that device, now and for every future login.

Why sk-* proves nothing

OpenSSH supports FIDO2 security keys since version 8.2, with the key types sk-ssh-ed25519@openssh.com and sk-ecdsa-sha2-nistp256@openssh.com. A server administrator may think that accepting only these types restricts logins to hardware. It does not.

OpenSSH loads the security key driver from a library chosen by the client, through the SSH_SK_PROVIDER environment variable. Any software can implement this interface and produce sk-* keys whose private part sits in a file. The server sees the same public key format and the same signature format. The key type is a claim by the client, not a proof.

The proof: FIDO2 attestation

We need a proof of hardware. A FIDO2 authenticator creates a credential with a single command, and the CTAP protocol has no command to import a private key. At creation, the authenticator signs an attestation statement with a key provisioned by the manufacturer. The statement contains the new public key and a challenge chosen by the caller.

ssh-keygen saves it on request:

ssh-keygen -t ed25519-sk -O no-touch-required \
    -O challenge=chal.bin -O write-attestation=attest.bin

The file attest.bin (format ssh-sk-attest-v01) holds the attestation certificate, the signature and the authenticator data.

A verifier must check four things:

  1. The attestation certificate chains to a pinned manufacturer root.
  2. The signature covers the authenticator data and SHA256(challenge).
  3. The public key inside the authenticator data is the SSH public key, for the same application (ssh:).
  4. The user presence flag is set, which means a human touched the key once, at creation.

On my YubiKey 5C Nano (firmware 5.8), the chain has four certificates: an end-entity certificate, “Yubico FIDO Attestation B2 1”, “Yubico Attestation Intermediate B 1”, and “Yubico Attestation Root 1”. Older YubiKeys chain directly to “Yubico U2F Root CA Serial 457200631”, so a verifier pins both hierarchies.

Enforcing it in sshd

The verifier is useless if the server reads keys from anywhere else. The sshd configuration has to close every other door:

AuthenticationMethods publickey
PubkeyAcceptedAlgorithms sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com
PubkeyAuthOptions none
AuthorizedKeysFile none
AuthorizedKeysCommand /usr/local/bin/hwssh authorized-keys --mds /var/lib/hwssh/mds.jwt /etc/hwssh/registry %u
PasswordAuthentication no
KbdInteractiveAuthentication no

Three design choices matter:

I tested the configuration end to end. A correct password is refused, a plain ssh-ed25519 key present in ~/.ssh/authorized_keys is refused, a forged registry entry is refused, and the YubiKey logs in with nobody touching it.

An independent check: the FIDO Metadata Service

Where do the pinned manufacturer roots come from? One can download them from Yubico’s website, which makes Yubico both the claimant and the reference.

The FIDO Alliance Metadata Service (MDS3) provides a second, independent source. It is a signed JSON Web Token listing every certified authenticator model, identified by its AAGUID, with its attestation root certificates and its status reports. Release no. 301 lists 537 models. Every Yubico certificate I pinned appears in it, byte for byte, and my key’s AAGUID resolves to “YubiKey 5 Series (Consumer Profile)”, certified at level L2.

With the blob, hwssh adds three checks at each login: the AAGUID is listed, the attestation path contains a certificate listed for that AAGUID, and no status report says REVOKED, ATTESTATION_KEY_COMPROMISE or USER_VERIFICATION_BYPASS. Without a fresh blob, no key is served, so the server fails closed.

What is proven, and what is not

Back to the three properties of a provable hardware key:

  1. Hardware-bound key generation holds. FIDO2 has no key import, and the attestation is produced at creation time inside the device.
  2. Verifiable non-exportability holds. Anyone with the public key, the attestation and the challenge can re-verify the claim offline with hwssh verify-registry, without access to the device or to the server’s secrets.
  3. Auditable execution does not hold. The YubiKey firmware is closed. The attestation is a statement by Yubico about a device model, not an audit of its code.

Two more limits remain. First, trust is rooted in the manufacturer. A leaked attestation key breaks the proof, and announcing such a leak is the purpose of the MDS status ATTESTATION_KEY_COMPROMISE. Second, FIDO attestation identifies a batch of devices, not one device, on purpose, for privacy. The proof says “this key lives in a YubiKey 5”, not “this key lives in YubiKey serial 38567500”. For enrollment, the challenge binds the attestation to one enrollment session; it does not prove which physical device the user held.

Unattended login has a price. Malware on the machine where the YubiKey is plugged in can log in without anyone noticing, but it cannot copy the key, so unplugging the YubiKey ends the access. A server that wants a human at every login serves the keys with the verify-required option, which demands the PIN.

Implementation

hwssh is about 700 lines of Python on top of cryptography and Yubico’s python-fido2. The verification of a login, including parsing the 11 MB metadata blob, takes 0.5 seconds. The test suite has a synthetic certificate authority that produces one valid attestation and about twenty invalid ones (wrong challenge, swapped public key, untrusted root, revoked model, stale metadata), plus a real attestation captured from my YubiKey.

The approach generalizes beyond SSH. The same verifier applies to any FIDO2 credential, and the same registry of evidence applies to any server that authenticates users with public keys.

Prior Art

Login-time enforcement. Smallstep’s ssh-attest-proxy (2025) is the closest to hwssh. A CA embeds the attestation in an SSH certificate, and a verifier on the server rejects “any certificate without an attestation”. It requires SSH certificates, pins one root, and its README says it is “educational” and that a production version “would implement key attestation verification in an SSH Certificate Authority, not on the SSH server itself”. I take the opposite position: a server that re-verifies the evidence at each login does not need to trust a CA, and anybody can audit its registry.

Verifiers. Several tools check one ssh-sk-attest-v01 file. Joost van Dijk wrote a proof of concept for SSH signatures pinned to the Yubico root (2022), then a Python script that looks up the AAGUID in the FIDO Metadata Service (2024), the closest prior use of MDS for SSH keys. The Rust library webauthn-rs has a sshkey-attest crate that verifies the attestation against a caller-supplied list of CAs. These are verification functions; none of them decides who gets into a server.

Products. Teleport Enterprise requires keys stored on a YubiKey PIV applet, verified when it issues short-lived certificates. Cloudflare Access (2026) enrolls FIDO2 SSH keys and restricts them to a list of allowed AAGUIDs at each connection. In both, verification happens in closed code, and the evidence cannot be checked by a third party. On the TPM side, Morten Linderud’s ssh-tpm-ca-authority issues 5-minute SSH certificates bound to TPMs after attestation of their endorsement key.

Collection without enforcement. Wikimedia’s hardware-backed SSH keys policy asks users to upload the challenge and the attestation files at enrollment, which is the only organization I found collecting this evidence.