I tried by adding below udev rule

ACTION=="add", SUBSYSTEMS=="usb", RUN+="/bin/sh -c 'for host in /sys/bus/usb/devices/usb*; do echo 0 > $host/authorized_default; done'"

ACTION=="add", ATTR{idVendor}=="054c" RUN+="/bin/sh -c 'echo 1 >/sys$DEVPATH/authorized'"

But it disabled all usb devices(USB keyboard and mouse).

Kindly suggest how can I allow other devices except storage devices.


You can use inequality for exceptions:

ACTION=="add", DRIVERS=="usb-storage", ATTRS{idVendor}!="054c", RUN+="/bin/sh -c 'echo 0 >/sys%p/authorized'"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.