How to protect Linux against rogue USB devices using USBGuard

· >

How to Protect Linux against Rogue USB Devices Using USBGuard

SBGuard is a Linux kernel module that allows you to create policies for USB devices based on their attributes. It can be used to prevent rogue USB devices from being connected to your system, as well as to block certain types of USB devices based on your security needs.

Install USBGaurd Package

To use USBGuard on your Linux system, you will need to install the usbguard package. This package is available in most Linux distributions and can be installed using the package manager. For example, on a Debian-based system, you can install it using the following command:

sudo apt-get install usbguard

Once the package is installed, you can start the USBGuard service by running the following command:

sudo systemctl start usbguard

You can then configure the USBGuard rules by editing the /etc/usbguard/rules.conf file. This file contains a set of rules that define how USBGuard should handle different types of USB devices.

For example, to block all USB storage devices, you can add the following rule to the file:

block with-interface equals {08:*}

This rule will block any USB device that has an interface class of 08, which corresponds to storage devices.

You can also create rules that allow certain types of devices based on their attributes. For example, to allow a specific USB keyboard, you can use a rule like this:

allow with-serial equals "123456"

This rule will allow a USB keyboard with the serial number “123456”. You can use similar rules to allow other types of devices, such as printers or mice.

Once you have created your rules, you can reload the USBGuard rules by running the following command:

sudo usbguard reload-rules 

This will apply the new rules and block or allow the appropriate devices.


By using USBGuard, you can protect your Linux system from malicious USB devices. USBGuard’s access control feature allows you to specify exactly which USB devices can access your system. However, it’s important to remember to use other security measures as well.

Notify of
Inline Feedbacks
View all comments