SSH with a FIDO security key never asks me to touch the key
When ssh shows "Confirm user presence for key", when the prompt goes through ssh-askpass instead, and how no-touch-required keys skip the touch altogether.
A FIDO security key normally needs a touch for every SSH login (user presence). OpenSSH tells you when to touch it, but where that message appears depends on who is signing: ssh itself, or ssh-agent.
ssh signs: the message is in your terminal
When ssh uses the key file directly and the key requires user presence, it prints:
Confirm user presence for key ED25519-SK SHA256:…
then waits for the touch. It writes this to the terminal when standard error is a terminal. Otherwise, and in batch mode, it tries the SSH_ASKPASS program instead.
ssh-agent signs: the message goes to ssh-askpass
If the key is loaded in ssh-agent (see Use an ed25519-sk security key with ssh-agent: ssh-add, providers and macOS), the agent does the signing, and ssh itself prints nothing about the touch. The agent shows the same "Confirm user presence" text only through the SSH_ASKPASS program, and only if:
DISPLAYorWAYLAND_DISPLAYis set, orSSH_ASKPASS_REQUIRE=force, and- an askpass program is set or installed.
Without those, there is no message at all, but the key still has to be touched. A login that seems to hang may just be waiting for the touch.
The key really does not need a touch
A key can be made so that it skips user presence:
ssh-keygen -O no-touch-requiredwhen the key is created. The current ssh-keygen manual also letsssh-keygen -pchange it later with-O touch-requiredor-O no-touch-required; with an older OpenSSH that does not accept this, make a new key.- On the server,
sshdstill requires user presence by default. It accepts a signature without a touch only if theauthorized_keysline for that key has theno-touch-requiredoption. - If the server's
sshd_configsetsPubkeyAuthOptions touch-required, the server ignores thatauthorized_keysoption and always requires a touch.
So if logins work with no touch at all, both the key and the server's authorized_keys line have been set up that way. To require the touch again, remove no-touch-required from the authorized_keys line, and change or replace the key.
Related
- Security keys (FIDO2) with SSH
- Use an ed25519-sk security key with ssh-agent: ssh-add, providers and macOS
- ssh-keygen "Key enrollment failed" for ed25519-sk: feature not supported, device not found
- Authorized keys and permissions
- App guide: YubiKey and security keys
Sources
- ssh-keygen(1): no-touch-required and touch-required with -O
- sshd(8): the no-touch-required authorized_keys option
- sshd_config(5): PubkeyAuthOptions touch-required
- ssh(1): SSH_ASKPASS and SSH_ASKPASS_REQUIRE
- OpenSSH source: "Confirm user presence" in ssh (sshconnect2.c)
- OpenSSH source: the agent's notice and when askpass is used (ssh-agent.c, readpass.c)