I’ve been using this since it was merged into OpenSSH, and can confirm how well this works.
It is quite refreshing compared to using gpg, which required 3 (!) daemons to work. You had to run a gpg-agent in ssh-agent mode, which spawned its own scdaemon, which communicated with pcscd (which you had to start yourself), which dynamically loaded a CCID module, which used libusb to finally talk to your device.
I saw that OpenSSH also supports ed25519-sk keys. Do you know which security key models support this? I have a super old Yubikey NEO (U2F only) and a Solo key, and neither of them do. Perhaps one of the newer Yubikey models?
It looks like YubiKey firmware v 5.2.3 from January 2020 includes curve 25519 support; it’s not clear to me if you can get this on the U2F-only models.
Thanks for the link. It sounds like any recent YubiKey 5 series should have this support.
The U2F protocol is specified to use P-256 keys, so you’d definitely need a FIDO2-capable device.
You could already use many YubiKey’s PIV application with OpenSSH through the OpenSC PKCS#11 support . Since some recent version of OpenSSH (8.0 IIRC), you could also use some elliptic curve keys through that route.
The U2F key support is cooler, because the keys are much cheaper. However, the PKCS#11 route has the benefit that it also supports authenticating with servers that have older OpenSSH versions, whereas the U2F support also requires that a server is on OpenSSH 8.2.
I only have to run gpg-agent on my Mac to use my Yubikey as an ssh key. I don’t manage any other daemons. Everything just works.
This is because macOS is always running a smart card services daemon, to support e.g. logins with a smart card and code signing with smart cards. So on the Mac only gpg-agent and scdaemon are needed, which are automatically started by gpg.
Does this still let you require that you must touch the Yubikey to use it? That’s the only safe way to use SSH agent forwarding
I just tried it and yes, it does.
Just to check, does this mean we can skip passphrases for the ecdsa-sk keys? ssh-keygen still asks for one, but assuming I’m comfortable with the security model of Yubikey possession == access, is a passphrase still necessary?
Yep, even without a passphrase for most tokens it’s still private key file + hardware token. With a passphrase it should be private key file + passphrase + hardware token. With resident credentials it’s just hardware token.
Awesome, thanks for confirming Filo!
To answer my own question: all I had to do was read past the first half of the article.
So in both cases access implies possession of the hardware token, and if I’m comfortable with that being sufficient then I’m free to skip adding a passphrase.
ssh-keygen -t ecdsa-sk
ssh-keygen -t ecdsa-sk
Can such a key be “connected” with another hardware token (e.g. if the primary token fails)?
On macOS, should you always be installing OpenSSH with Homebrew to get this and other updates? I don’t normally install OpenSSH, but I do use Homebrew extensively for other things.
macOS is at OpenSSH 8.1 so it doesn’t support it and we don’t know yet if they’ll build it with the native support.
Unfortunately installing from Homebrew doesn’t replace the system-provided ssh-agent, so the agent started automatically by the OS won’t be able to load the ecdsa-sk key type.
SIP won’t let you modify the /usr/bin/ssh-agent binary nor edit the launchd plist. In theory you could create a new launchd service to run the brew-installed ssh-agent but then you lose Keychain support for the passphrase. Depends if that’s important to you.
Oh, fascinating. macOS does indeed run a default on-demand ssh-agent, and the socket path is magically passed in the environment of login shells. I did not know this! Kinda surprised that Homebrew would ship its own ssh-add by default when again by default it would talk to the system ssh-agent. I wonder what the backwards compatibility of that protocol is.
The good news is that if I read this right we’d be able to load the Homebrew FIDO2 middleware into the system agent if they don’t build it.
The bad news is that Apple squatted on “ssh-add -K” for keychain support, and now that’s a real option for loading resident keys 🤷♂️
The did update the OpenSSH version that originally came with Catalina, 7.9 to 8.1 now. So let’s hope that there will be a 10.15.5 with OpenSSH 8.1.
Thanks for sharing! I’m going to try and get it working with the FIDO2 app on my Ledger Nano S.
Can anyone point me to a good review/comparison of the available U2F keys?