I recently bought myself a Yubikey 4, as previously mentioned.

Here's what I've managed to do with it so far ...

General observations

Since this is very new hardware, it comes as no surprise that the versions of the Yubikey tools in Debian stable aren't new enough to talk to it. I used the Windows versions off the Yubico website to have a poke around the settings, but if the device is already in OTP+U2F+CCID mode, then that should cover all bases.

The device arrived just over 1 business day after I'd ordered, sent from a UK distributor - having had to order and pay in dollars via PayPal, it wasn't clear that this would be so snappy. Well done Yubico.

Physically, it fits nicely onto my keyring and is barely any more noticeable than the two small USB drives and other bits and pieces hanging on there. Though its arrival did inspire me to purge my keyring of quite a lot of keys I'd been carrying around for years and almost never using. Weight is a concern when you're dangling your keys on the end of a USB-connected device (mostly in case they pull it out of the port rather than the risk of physical damage in this case), so digging out an extension cable to let the keys rest on my desk was necessary to connect to my desktop. Laptops are naturally more convenient here.

U2F (Universal Second Factor)

I didn't buy it for this particularly - until there's Firefox support, U2F is a bit too edge-case for me. However, with the addition of the relevant udev rules (easily Google-able), it does work with Google Chrome on Debian and is a more convenient alternative to the Google-Authenticator based two-factor auth I already had enabled on my Github and Google accounts. The nice thing is that both services will fall back to accepting codes from the app on your phone if a U2F token isn't present, so it's low-risk to turn this on. The Yubikey is more convenient than having to dig out my phone and transcribe a code, though (not least because a security-conscious nerd like me now has over a screenful of entries in the app) - and is also impervious to the phone running out of battery or otherwise failing.


Other than confirming it works on Yubico's demo site, I've not found a use for this just yet. It's worth noting that, if I understand correctly, it relies on Yubico having the corresponding public key to the private key embedded in the device, and thus uses require authenticating against Yubico's servers. It is possible to insert your own key onto the device and run your own auth service, but that seemed a bit much effort for one person (and hard to convince myself it'd be more secure in the long run). Meanwhile, I see I could use the Yubikey as a second factor for key-based SSH authentication, or even a second factor for sudo. But in both cases it would require Yubico's servers being up to authenticate the second factor, and I'm not sure what my backup plan for that would be. At the very least, I'd want to own a second Yubikey as fallback before locking down any service to the point where I couldn't get in without one.


This was the main use-case I bought the Yubikey for. Previously I'd had a single RSA PGP key which I used for both encrypting and signing. The difficulty with this set-up is that you end up wanting the private key key on half a dozen machines which you regularly use for e-mail, but the more places you have it, the more likely it is to end up on a laptop that gets stolen or similar.

For my new key, I've switched to a more paranoid setup which involves keeping the master key completely offline, and using sub-keys on the Yubikey to sign/encrypt/authenticate - these operations are carried out by a dedicated chip on the Yubikey and the keys can't be retrieved from it. You're still required to enter a PIN to do these operations, in addition to having physical possession of the Yubikey and plugging it in. However, the nice trick about the sub-keys is that in the event of the Yubikey being lost/stolen, you can simply revoke them and replace them with new ones - without affecting your master key's standing in the web of trust.

The Yubikey 4 supports 4096 bit RSA PGP keys - unlike its predecessors which were capped to 2048 bits. To make all this work, you need to use the 2.x series of GnuPG - 1.x has a 3072 bit limit on card-based keys and even that turned out to be more theoretical than achievable. I couldn't initially persuade GnuPG 2.x (invoked as gpg2 on Debian/Ubuntu) to recognise the Yubikey, but a combination of installing the right packages (gnupg-agent, libpth20, pinentry-curses, libccid, pcscd, scdaemon, libksba8) and backporting the libccid configuration from a newer version finally did the trick, with gpg2 --card-status displaying the right thing. Note that if running Gnome, some extra steps may be required to stop it interfering with gnupg-agent (but you should get a clear warning/error from gpg2 --card-status if that's the case).

I generated my 4096 bit subkeys on an offline machine (a laptop booted from a Debian live CD) and backed them up before using "keytocard" in gpg to write them to the Yubikey.

I got into a bit of a tangle by specifying a 5 digit PIN - gpg (1.x) let me set it but then refused to accept it, saying it was too short! Fortunately I'd set a longer admin PIN and the admin PIN can be used to reset the main PIN. I'm not sure if that was just a gpg 1.x bug, but I've gone for longer PINs to be safe.

Having waded through all that, the pay-off is quite impressive: Enigmail, my preferred solution for PGP and e-mail, works flawlessly with this set-up. It correctly picks and uses sub-keys marked as for encryption purposes, and it prompts for the Yubikey PIN exactly as you'd expect when signing, encrypting and decrypting. It's worth having a read of the documentation, and giving some consideration to the "touch to sign" facility. This goes some way towards making up for the Yubikey's weakness compared to some more traditional PGP smart cards: it doesn't have a trusted keypad for you to enter your PIN, so there's always the risk of it being intercepted by a keylogger. But touch to sign means malware can't ask the key to sign/encrypt/decrypt without you touching the button on the key for each operation. In any case, this set-up is a quantum leap over my old one and means I can make more use of PGP on more machines, with less risk of my key being compromised.

It's worth noting that the Yubikey is fully supported on Windows and is recognised by GnuPG there too. This set-up might finally persuade me that a Windows machine can be trusted with doing encrypted e-mail.