libfido2 icon indicating copy to clipboard operation
libfido2 copied to clipboard

Unable to generate a ed25519 key with latest ubuntu/libfido2/firmware

Open jflebeau opened this issue 6 years ago • 12 comments

The key is a 5C Nano.

ssh-keygen -t ed25519-sk -f ~/.ssh/id_ed25519_sk produces Key enrollment failed: invalid format

libfido2-1 is at latest version: 1.4.0~ppa~focal1

ssh -V gives OpenSSH_8.2p1 Ubuntu-4ubuntu0.1, OpenSSL 1.1.1g 21 Apr 2020

Using the yubico manager UI, I checked the firmware version: 5.2.6

jflebeau avatar Aug 13 '20 19:08 jflebeau

Hi,

ssh-keygen -t ed25519-sk on a 5.2.6 key works for me on Focal with libfido2 as packaged by Ubuntu (1.3.1-1ubuntu2), and with libfido2 as packaged by Yubico (1.4.0~ppa~focal1). The only difference in my setup is that I have OpenSSL 1.1.1f instead of OpenSSL 1.1.1g. If you install fido2-tools, what is the output of fido2-token -L?

-p.

martelletto avatar Aug 14 '20 07:08 martelletto

fido2-token -L -> /dev/hidraw5: vendor=0x1050, product=0x0407 (Yubico YubiKey OTP+FIDO+CCID)

jflebeau avatar Aug 14 '20 11:08 jflebeau

Thanks. Is that the entirety of fido2-token's output, or do you have other security keys connected to your machine?

martelletto avatar Aug 14 '20 11:08 martelletto

Yes, I don't have another security key.

jflebeau avatar Aug 14 '20 11:08 jflebeau

Ok. Is FIDO2 enabled on the key? You can check this with 'ykman info | grep -i fido' from the command line, or using YubiKey Manager's GUI. Alternatively, is ssh able to talk to the key, i.e. does 'ssh-keygen -vvv -t ecdsa-sk' work?

martelletto avatar Aug 14 '20 11:08 martelletto

Yeah FIDO2 was enabled (from the GUI), as I was poking around I tried to do a reset from the GUI, then it worked 🤔

jflebeau avatar Aug 14 '20 11:08 jflebeau

Do I understand correctly that 'ssh-keygen -t ed25519-sk' started working once you reset the FIDO2 application from YubiKey Manager? That's very strange.

martelletto avatar Aug 14 '20 11:08 martelletto

Exactly, but now I'm struggling with a sign_and_send_pubkey: signing failed for ED25519-SK "xxx" from agent: agent refused operation

jflebeau avatar Aug 14 '20 12:08 jflebeau

One way in which I can reproduce https://github.com/Yubico/libfido2/issues/202#issue-678693820 and https://github.com/Yubico/libfido2/issues/202#issuecomment-674033689 with a YK 5 NFC with Firmware 5.2.6 (and probably other keys as well) is by providing an incorrect PIN until the FIDO2 applet is blocked before invoking ssh-keygen:

~$ ssh-keygen -t ed25519-sk -f ~/.ssh/id_ed25519_sk -vvv
Generating public/private ed25519-sk key pair.
You may need to touch your authenticator to authorize key generation.
debug3: start_helper: started pid=140182
debug3: ssh_msg_send: type 5
debug3: ssh_msg_recv entering
debug1: start_helper: starting /usr/lib/openssh/ssh-sk-helper 
debug1: sshsk_enroll: provider "internal", device "(null)", application "ssh:", userid "(null)", flags 0x01, challenge len 0
debug1: sshsk_enroll: using random challenge
debug1: ssh_sk_enroll: using device /dev/hidraw0
debug1: ssh_sk_enroll: fido_dev_make_cred: FIDO_ERR_PIN_REQUIRED
debug1: sshsk_enroll: provider "internal" returned failure -3
debug1: ssh-sk-helper: Enrollment failed: incorrect passphrase supplied to decrypt private key
debug1: ssh-sk-helper: reply len 8
debug3: ssh_msg_send: type 5
debug1: client_converse: helper returned error -43
debug3: reap_helper: pid=140182
Enter PIN for authenticator: 
debug3: start_helper: started pid=140183
debug3: ssh_msg_send: type 5
debug3: ssh_msg_recv entering
debug1: start_helper: starting /usr/lib/openssh/ssh-sk-helper 
debug1: sshsk_enroll: provider "internal", device "(null)", application "ssh:", userid "(null)", flags 0x01, challenge len 0 with-pin
debug1: sshsk_enroll: using random challenge
debug1: ssh_sk_enroll: using device /dev/hidraw0
debug1: ssh_sk_enroll: fido_dev_make_cred: FIDO_ERR_PIN_AUTH_BLOCKED
debug1: sshsk_enroll: provider "internal" returned failure -1
debug1: ssh-sk-helper: Enrollment failed: invalid format
debug1: ssh-sk-helper: reply len 8
debug3: ssh_msg_send: type 5
debug1: client_converse: helper returned error -4
debug3: reap_helper: pid=140183
Key enrollment failed: invalid format

fmeum avatar Aug 14 '20 12:08 fmeum

@FabianHenneke, indeed, that probably explains what @jflebeau saw. Thank you. @jflebeau, try ssh -vvv -i <private_key_path> <host>.

(earlier comment sent from wrong account) :)

martelletto avatar Aug 14 '20 13:08 martelletto

@martelletto this is probably the wrong place to discuss this further... I already checked with -vvv.

ssh reaches this stage: sign_and_send_pubkey: signing using [email protected] SHA256:xxx then the key flashes for a while then it fails with sign_and_send_pubkey: signing failed for ED25519-SK "id_ed25519_sk" from agent: agent refused operation then it failover succesfully with another identity file (without a security key).

Server is also Ubuntu 20.4 / OpenSSH_8.2p1.

jflebeau avatar Aug 14 '20 13:08 jflebeau

What I am trying to say is that ssh-agent does not need to be involved, at least not in this stage. To make sure the key is usable, try ssh -i . If the key works and you need ssh-agent, then you can add it to the agent. Anyway, you are right that this isn't the right forum. Closing the ticket; good luck. :)

martelletto avatar Aug 14 '20 13:08 martelletto