USBGUARD-RULES.CO(5) USBGUARD-RULES.CO(5) (NAME) usbguard-rules.conf - USBGuard (DESCRIPTION) usbguard-rules.conf USBGuard usbguard-daemon.conf(5) . << >> . (RULE LANGUAGE) USBGuard USB . USB . (target) (allow) (block) (reject) . . . BNF : rule ::= target attributes. target ::= "allow" | "block" | "reject". attributes ::= attributes | attribute. attributes ::= . . << >> <<>> . (Targets) . : o allow - . . o block - . . o reject - . . (Device Specification) . . . usbguard-daemon.conf(5) . . (Device Attributes) USB . . . : o (single-valued) : name value o (multi-valued) : name [operator] { value1 value2 ... } operator () : all-of . one-of . none-of . equals . equals-ordered . match-all . equals . : id usb-device-id USB. id [operator] { usb-device-id ... } USB. hash "value" USB. USBGuard . hash [operator] { "value" ... } . parent-hash "value" . parent-hash [operator] { "value" ... } . name "device-name" USB. name [operator] { "device-name" ... } USB. serial "serial-number" iSerial USB. serial [operator] { "serial-number" ... } iSerial USB. via-port "port-id" USB . . . parent-hash . via-port [operator] { "port-id" ... } USB. with-interface interface-type USB . with-interface [operator] { interface-type ... } USB . with-connect-type "connect-type" USB port/connect_type. with-connect-type [operator] { "connect-type" ... } USB port/connect_type. label "label" . (Label) . . usb-device-id vendor_id:product_id . USB USB . vendor_id product_id () . *:* 1234:* . port-id USB . USB ( <>) "usbN" USB "bus-port[.port[.port ...]]" ( 1-2 1-2.1 ...) . interface-type USB cc:ss:pp. (cc) (ss) (pp) USB-IF . . (*) . . (Conditions) . . (true) . . : if [!]condition if [operator] { [!]conditionA [!]conditionB ... } (!) . : all-of (true) . one-of (true) . none-of (true) . equals all-of. equals-ordered all-of. : localtime(time_range) (true) . time_range HH:MM[:SS] HH:MM[:SS]-HH:MM[:SS] . allowed-matches(query) (query) (true) . . . rule-applied (true) . rule-applied(past_duration) (true) . past_duration HH:MM:SS HH:MM SS . rule-evaluated (true) . rule-evaluated(past_duration) (true) . past_duration HH:MM:SS HH:MM SS . random p(true)=0.5 / . random(p_true) p(true)=p_true . true (true) . false (false) . (Partial rule) (target) . usbguard . (Comments) . "#" . (INITIAL POLICY) usbguard generate-policy . allow . usbguard(1) . . . : $ sudo usbguard generate-policy > rules.conf $ vi rules.conf (review/modify the rule set) $ sudo install -m 0600 -o root -g root rules.conf /etc/usbguard/rules.conf $ sudo systemctl restart usbguard (EXAMPLE POLICIES) rules.conf . 1. USB ( USB) . USB . . : allow with-interface equals { 08:*:* } block . . USBGuard . 2. Yubikey ( ) allow 1050:0011 name "Yubico Yubikey II" serial "0001234567" via-port "1-2" hash "044b5e168d40ee0245478416caf3d998" reject via-port "1-2" . name serial . . . 3. USB . USB ( ) . allow with-interface equals { 08:*:* } reject with-interface all-of { 08:*:* 03:00:* } reject with-interface all-of { 08:*:* 03:01:* } reject with-interface all-of { 08:*:* e0:*:* } reject with-interface all-of { 08:*:* 02:*:* } USB HID/Keyboard Communications Wireless . . . <<>> . 4. USB USB allow with-interface one-of { 03:00:01 03:01:01 } if !allowed-matches(with-interface one-of { 03:00:01 03:01:01 }) 5. << >> USB allow if random(0.1666) reject (SEE ALSO) usbguard-daemon(8), usbguard-daemon.conf(5) (BUGS) https://github.com/USBGuard/usbguard/issues/new . (AUTHOR) USBGuard Daniel Kopecek . . (RESOURCES) : https://usbguard.github.io (COPYING) GPLv2+: GPL http://gnu.org/licenses/gpl.html. : . . 09/05/2026 USBGUARD-RULES.CO(5)