by convolvatron · 7y ago · 0 comments
this seems like such an overwhelmingly common use case I dont understand why yubico doesnt make this as frictionless as possible. i understand that the smart card spec is probably a hindrance, but still..
but its still on my (physical) keychain, looking forward to trying your non-gpg workflow. thanks for posting.
I also got GPG agent forwarding to work transparently and with improved security by forwarding a dynamically created unix socket instead of a TCP socket. It allows me to do remote code signing, as well as chain through a bastion host.
Aside from jamming up with ansible occasionally, the setup is reliable.
I've documented the process for my own reference as much as I could here (yep, a fifth guide): https://github.com/naggie/dotfiles/blob/master/etc/yubikey.m... -- see functions.sh in the same repository for some mechanisms to automatically manage gpg-agent and the sockets without getting deadlocked.
I hope someone finds this useful. I'll certainly be trying the opensc method here though, out of interest.
Do you have a strong opinion on `on` vs `fixed` ? I tell myself that I should use fixed but haven't bitten the bullet yet.
Also I further mitigate the risk by having an explicit wrapper (gssh) to be selective about when I forward GPG/SSH agent.
I found that forwarding the scdaemon socket is more reliable. I configure GPG on the remote machine to use netcat as scdaemon.
To get started, you need the following packages:
ykpers (library and tools to program Yubikeys)
yubico-piv-tool (Yubico Personal Identity Verification (PIV) Tool)
pcsc-lite (resource manager for PC/SC)
opensc (set of libraries and utilities to access smart cards)
And the first thing I thought was "sure to be a guaranteed cluster fuck."Can't there be a better way already? We all know sec is a big deal. Don't we?
The specific "smartcard" protocol that Yubico uses for this functionality is well-supported by the three major operating systems, though (winscard is a standard library on Windows, PCSC.framework is standard on Mac OS, and libpcsclite is available on Linux by installing pcscd/pcsc-lite).
I recently implemented a library (https://github.com/pyauth/exile) to use Yubikeys to sign AWS API requests, which required writing a Python ctypes API to talk to these libraries. It turned out to be fairly easy once I threw away the idea that I should rely on any of the libraries you listed, and just started talking via the winscard/PCSC protocol directly.
If anyone wants to write something similar for this application, the ctypes bindings are in https://github.com/pyauth/exile/tree/master/exile/scard, and https://github.com/pyauth/exile/blob/master/exile/ykoath contains an example of how to use them.
Actually there is one pain point: every time I install a new system I have to remember to install the right packages and udev rules to be able to communicate with my yubikey from gnupg as a non-priviledged user.
But once it works it just works and it's a significant quality of life and security improvement.
Other stuff you can do with smartcards https://github.com/EnigmaBridge/javacard-curated-list
Once you have them use these guides to install
https://github.com/philipWendland/IsoApplet/wiki/Installatio...
https://github.com/philipWendland/IsoApplet/wiki/Initializat...