How can I check using a script that CD-drive is connected to USB port?

I don't want to allow cd-rom to be used as usb device under any circumstance in my system. Is there a way to check this?

  • Open up all computers, unsolder USB ports, done. (Don't try to "block USB" in software - someone will find a backdoor). – dirkt Feb 17 at 14:27
  • Could you clarify what you mean by “cd rom can be used as a usb device”? – Stephen Kitt Feb 17 at 14:54
  • I remember that in windows when you use a cd for the first time it asks if you want to use it as a usb or as a flash drive..So if you choose the usb mode it will be equivalent to a pendrive.. – network Feb 17 at 14:57
  • What? What is a hard-drive by USB? What is USB mode vs flash drive mode of a CD? What What What, this makes no sense to me. Please edit question, remove all jargon, use plain English. – ctrl-alt-delor Feb 17 at 18:13
  • 1
    Where does this strange requirement come from? An XY problem perhaps? – vonbrand Feb 19 at 18:15

I would use USBGuard for this,

The USBGuard software framework helps to protect your computer against rogue USB devices (a.k.a. BadUSB) by implementing basic whitelisting and blacklisting capabilities based on device attributes.

I would then create a whitelist of device IDs that are allowed to be used, and block everything else.

See: https://usbguard.github.io/documentation/rule-language.html

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