Skip to content

Instantly share code, notes, and snippets.

@Psmths
Created August 16, 2023 18:42
Show Gist options
  • Save Psmths/782e9d2ee0a8a167decd6ed2682eafc4 to your computer and use it in GitHub Desktop.
Save Psmths/782e9d2ee0a8a167decd6ed2682eafc4 to your computer and use it in GitHub Desktop.
Linux: Preventing certain USB devices from connecting

Step 1: Identify the Bus/Device pair of the device

# lsusb
...
Bus 005 Device 014: ID 05ac:12a8 Apple, Inc. iPhone 5/5C/5S/6/SE
...

In this instance, the bus ID is 005 and the device ID is 014.

Step 2: Determine the vendor ID and product ID

Issue the lsusb command with the bus and device ID parameters in the format Bus ID:Device ID, in this case it would be 005:014:

# lsusb -vs 005:014 | grep -E 'idProduct|idVendor'
  idVendor           0x05ac Apple, Inc.
  idProduct          0x12a8 iPhone 5/5C/5S/6/SE

Step 3: Add a new udev rule to block the device

Create a new udev rule file such as:

/etc/udev/rules.d/10-block-phone.rules

In this file, the contents should be as follows, given the output from the previous lsusb command:

SUBSYSTEM=="usb", ATTRS{idVendor}=="05ac", ATTRS{idProduct}=="12a8", ATTR{authorized}="0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment