11.4. Permanently blocking and authorizing a USB device
You can permanently block and authorize a USB device by using the -p option. This adds a device-specific rule to the current policy and persists across restarts and reboots. USBGuard uses the terms block and reject with the following meanings:
block- Do not interact with this device for now.
reject- Ignore this device as if it does not exist.
Prerequisites
-
The
usbguardservice is installed and running.
Procedure
Configure SELinux to allow the
usbguarddaemon to write rules.Display the
semanageBooleans relevant tousbguard.# semanage boolean -l | grep usbguard usbguard_daemon_write_conf (off , off) Allow usbguard to daemon write conf usbguard_daemon_write_rules (on , on) Allow usbguard to daemon write rulesIf the
usbguard_daemon_write_rulesBoolean is turned off, turn it on.# semanage boolean -m --on usbguard_daemon_write_rules
Determine the ID of the USB device by listing the devices recognized by USBGuard:
# usbguard list-devices 1: allow id 1d6b:0002 serial "0000:00:06.7" name "EHCI Host Controller" hash "JDOb0BiktYs2ct3mSQKopnOOV2h9MGYADwhT+oUtF2s=" parent-hash "4PHGcaDKWtPjKDwYpIRG722cB9SlGz9l9Iea93+Gt9c=" via-port "usb1" with-interface 09:00:00 ... 6: block id 1b1c:1ab1 serial "000024937962" name "Voyager" hash "CrXgiaWIf2bZAU+5WkzOE7y0rdSO82XMzubn7HDb95Q=" parent-hash "JDOb0BiktYs2ct3mSQKopnOOV2h9MGYADwhT+oUtF2s=" via-port "1-3" with-interface 08:06:50Permanently authorize a device to interact with the system:
# usbguard allow-device <ID> -pPermanently deauthorize and remove a device:
# usbguard reject-device <ID> -pPermanently deauthorize and retain a device:
# usbguard block-device <ID> -p
Verification
Check that the USBGuard rules include the changes you made.
# usbguard list-rules