Open ckcr4lyf opened 5 months ago
One technique is, once the Yubikey is plugged in, monitor udev events via:
udevadm monitor --environment --subsystem-match=usb --kernel
Then, remove the Yubikey. Among various things, it would print something like
KERNEL[532212.884533] remove /devices/pci0000:00/0000:00:14.0/usb1/1-3 (usb)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-3
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/001/097
DEVTYPE=usb_device
PRODUCT=1050/407/526
TYPE=0/0/0
BUSNUM=001
DEVNUM=097
SEQNUM=24352
MAJOR=189
MINOR=96
This gives the PRODUCT
version you can use to add a udev rule. For a Yubikey removal, the rule should look like:
ACTION=="remove", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}=="1050/407/526", RUN+="/path/to/whatever.sh"
Unlike a normal drive, it is a bit harder to view the Yubikey info using
lsblk
etc.