Yubikey/Smartcard backed TLS servers
blog.benjojo.co.uk
blog.benjojo.co.uk
I checked the "NIST List" (rhymes haha), and they might have this module under evaluation:
https://csrc.nist.gov/Projects/Cryptographic-Module-Validati...
https://shop.nitrokey.com/shop/product/nitrokey-hsm-7
I've bought one, but didn't use it yet. I had ideas to use it to test an HSM + pkcs11 OpenSSL engine setup in a personal project (RFC3161 server), but I didn't found the time to play with it yet.
However, the standard tooling to interact with a P11 device under Linux is a bit of a mess, you have tooling from gnutls, p11-kit and OpenSSL (kind of actually, they kind of broke arguments passing, for example the URI of the key not being a valid path, when using external engines).
Also, if you want to play with an HSM without a physical HSM, softhsm is for you (https://www.opendnssec.org/softhsm/).
Does anyone use their OpenPGP key as their letsencrypt account key? How would you convert the signatures from gpg into the jws for the letsencrypt ACME API?
The main selling aspect is to avoid your private keys from being leaked to the world. For that there is all sort of tamper proofing on usually what is a PCIe card. They can also be sold as appliances.
Also, they tend to be a bit crappy. I had a really bad experience with Safenet Luna SE at my last job. The thing was buggy as hell, performance tended to be random between devices and on the security side, it was a CentOS 6.0 (with no updates) and a custom kernel driver + some userland tools which strangely enough, creates devices under /dev that were world writable...
The Luna SA seemed better, but their rackmount appliances where nothing to be proud of: cheap 1U chassis, with regular desktop parts (micro ATX motherboard, a cheap celeron, non ECC RAM). The one we opened with quite old however (Luna SA 4 IIRC).
The Thales ones seemed better at least in term of finish. The base appliance seemed to be of overall far better quality (sturdier case). But I didn't play with it, so no opinions on overall performance and ease of use.
https://developers.yubico.com/YubiHSM2/Usage_Guides/OpenSSL_... (for the YubiHSM2, but the YK4 also supports PKCS#11 with OpenSC)
P.S. The color caps on those yubikeys in the photo are cool, are they 3D printed?
Yup the caps are 3d printed! https://twitter.com/Benjojo12/status/929445558275756032
(I’m happy to accept that it’s GPG behaving badly here; the bottom line is just that if you want to use your card for and GPG and SSH and apparently TLS, gpg might be easier to get working than trying to use gpg + anything else. FWIW I hear gpgtools (the Mac distribution) merged a patch that fixed that behavior.)
Here is a tutorial is anyone is interested: https://developers.yubico.com/PIV/Guides/SSH_with_PIV_and_PK...
- You can put "PKCS11Provider /usr/lib...." in your .ssh/config file (even tied to a specific Host block) to make it load the module automatically instead of having to use an argument every time you run ssh/sftp/scp/etc.
- For windows, putty-cac works well with the built-in smartcard/crypto API (CAPI), even on machines where you don't have administrative access (like my work machine). It even has its own version of pageant, so it'll work with tools like WinSCP as well.
https://risacher.org/putty-cac/ https://github.com/NoMoreFood/putty-cac/releases
Do you know a solution for that?
ssh-add -s /usr/lib/....
But, it's acting funny for me, particularly if I remove the key.
(I'm not affiliated, or even a paying customer. I just benefit from freeloading off their freemium model.)
This is not in any way to take away from how impressive the OP's work is, how nicely it's written up, or the merits of: understanding this yourself, running on a Yubikey instead of a phone, and running independently of someone else's distribution chain (unless you build the phone app and daemon yourself) and infrastructure. If you're in the subset whose response to OP includes “I wish I could do this with my phone, and that someone else would set this up for me so I didn't have to understand it”, [1] might be of interest; otherwise, not.
[1] https://krypt.co
[2] https://github.com/kryptco
[3] https://news.ycombinator.com/item?id=14490766 – previous, mostly-skeptical, HN discussion
[4] https://news.ycombinator.com/item?id=16915819 – more recent discussion
Building on this, in Centos epel, there is a package "google-authenticator" which can generate 2fa for your account. It can also be turned on via a pam policy for all accounts.
There's also LinOTP which has a web service and web administration. If you need something more than just 2fa (like 2fa+salt) then you want LinOTP. And being able to integrate it into API calls is also really handy for re-requesting security access.
The simplest project was getting the One Time Password working for SSH & Local authentication on my OpenBSD laptop: https://www.romanzolotarev.com/openbsd/yubikey.html
The next one I tried was using the YubiKey as a smart card in conjunction with gpg-agent for making ssh connections. This did not work out. I couldn't figure out how to add the certificates loaded into gpg2 into gpg-agent using ssh-add. It might me some quirkiness unique to NixOS. I'm looking forward to trying with a different linux distro. Used this guide here: https://rzetterberg.github.io/yubikey-gpg-nixos.html
Overall I have been a fan of YubiKeys since 2013. I hope they continue growing the product.
In any case, I would expect any slowdown to be simply because the Yubikey is slower at doing cryptographic operations, not because of any overhead associated with USB. On my system, generating a 4096-bit RSA signature with OpenSSH takes about 4ms, whereas a bit of googling suggests a no-op USB round-trip is on the order of 200us.
Also, the fact that it requires being plugged (powered) to generate a HOTP token makes it very resistant to my kids who invalidate my work's LCD-with-button keyfob all the time.
We chose to go another way because you still need another MFA for many use cases.
- Yubikey as PIV token, works well on Windows, other OSes require OpenSC, doesn’t play nicely if you want to use GPG as well
- Yubikey as GPG token only, and using Scute as a PKCS11 emulator on top of GPG agent.
I’m currently using the scute method, but it doesn’t play that well with Windows (Cryptographic Service Provider), and Scute itself doesn’t seem that well used or maintained. Ideally I’d be able to use my Yubikey as a GPG card and have seemless TLS client auth and Windows Smartcard logon.
I just ran into this a few days ago. I was having a hard time debugging why the token would randomly lock up when I tried to do client auth in firefox/opensc while the yubikey had PGP mode unlocked.
> Scute
Thanks for the pointer! This seems to be exactly what I was looking for.