How to Block USB storage in CentOS 7 

How to Block USB Storage in CentOS 7

When you connect a USB storage device to your computer, by default it will mount the storage and allows the user to access the content, although the method is simple, it is not absolutely secure and is prone to malicious actions or attack on your system. You can handle this problem with some easy configuration and this tutorial covers one such method which disables USB storage in CentOS 7.


Disabling USB Storage

In order to disable the USB storage, you need to create a .conf file and edit it using a text editor.

root@linuxhelp ~ # vim /etc/modprobe.d/usb-storage.conf

Enter the following lines in the file.

install usb-storage /bin/true
~
~
~
:wq 

The above .conf file reflects fake installation of USB storage. Let us see how the above configuration affects our attempt to insert a USB device to the system.


When you insert a USB device, the following action takes place.
/bin/true is a command that returns zero “

True &ndash does nothing
True returns a status 0.

Now we need to reboot the machine to complete the process.

root@linuxhelp ~ # reboot


Now, if you plug a USB storage device you should not be able to access it. You can check it by running the following command.

In previous CentOS 6 version, you need to do the configuration in /etc/modprobe.conf, but in CentOS 7 it is deprecated and unique file must exist with the /etc/directory.d directory instead.

With this, this tutorial on blocking USB storage in CentOS 7 comes to an end. You can use this technique to prevent access to USB storage devices for unprivileged user accounts which can increase system security against certain physical attack vectors.

Tag : CentOS
Comment
julienduchet
Sep 05 2018
hello @mason, thanks for your tips. but is there a way to block usb data, but still keep usb power going through on centOS 7. this is something we are trying to achieve at my job, but we had to cut everything. and people are complaining that they can't charge their phone anymore. thanks for your help.
Add a comment
FAQ
Q
Do I need install driver for using USB Flash Drive?
A
If your USB Flash Drive is formatted as FAT32, you need not to install any driver for Windows 7 and
other newer operating systems.
Q
Can I use USB Flash Drive with Mac or Linux computer?
A
Yes, you can use USB Flash Drive with Mac or Linux computer if there is USB port. The Mac OS
should be version 9 or later, and Linux kernel should be version 2.4.0 or later.
Q
How Can USB Flash Drives Be So Small?
A
USB flash drives use solid state flash technology, which stores data without using moving parts, as most physically larger internal PC hard drives do.
Q
How to do the same in centos/rhel6?
A
Use the configuration under "/etc/directory.d " instead of "/etc/modprobe.conf"
Q
Its is not working out after done with the configuration?
A
Have you rebooted your system so that the effect can take place