logoalt Hacker News

mmulqueen • today at 5:19 PM • 0 replies • view on HN

Yubikey or another removable security key is the way to go in my opinion. I've been doing this since I think 2018. There are few ways you can do it, I've always used the GPG key option - you have the GPG key irretrievably on the Yubikey, you set up SSH to talk to gpg-agent and you have to provide a PIN every time you plug the USB back in. When I walk away, the Yubikey goes with me. I've never had a problem getting it working with anything on Linux or any external service. You can either let existing sessions continue or there are ways you can break existing sessions when the key is unplugged. Works on Windows and macOS too, from memory, macOS was almost as easy as Linux and Windows is more fiddly.

By having it as a GPG key, you get signing and encryption on top of SSH. You can pair it with gopass as a password vault.

I haven't had to make a new key for years, they're very hard-wearing, mine lives on my key ring with my house keys. But I wrote this script to automate setting up a new key, I haven't tested it with recent Yubikeys or a recent version of GPG, but might be a useful starting point: https://github.com/Method-B-Ltd/auto-gpg-card - PRs welcome if it's broken.

You still need to be really careful about what can run as your user, but being able to take the key away physically remove a load of risk.