usb-ks is a USB killswitch program, inspired by https://github.com/BusKill/buskill-app, but simplified and written in Go instead of Python. Additionally, usb-ks executes the specified command on all USB device changes, not just disconnects. When governments seize devices they often use USB devices to exfiltrate data and to ensure systems with FDE don't shutdown. It is thusly evident shutdown behaviors should be initiated on connection and disconnection.
go install github.com/andrewlaack/usb-ks@e41c1fdaf9126800589957a3bdd568fa96086ce5
Then optionally:
sudo install ~/go/bin/usb-ks /usr/local/bin/
NOTE: ensure your go installation directory (default: ~/go/bin) is on your path as this is the default installation location. If you run the optional command, ensure the first argument to install contains the correct go installation path.
- go
- for building
- libudev
- for listening to usb device changes
- a shell
- /bin/sh to execute the specified command
Basic invocation, executing xscreensaver on USB device change:
usb-ks
NOTE: Since xscreensaver does not shutdown your system (i.e. doesn't engage FDE protections), it may not be desirable for certain threat models.
For better protection, I recommend using poweroff:
usb-ks poweroff
See options:
usb-ks --help