I want to block usb mass storage in some of the systems in the LAN. I have written a bash script which will modify the file. I am running the script as default admin in ubuntu. But the script is not able to modify the file. I am getting the following error "bash: /etc/modprobe.d/blacklist.conf: Permission denied"
Below is my bash script
#/bin/bash
password='mypassword' #admin password of remote system
val='blacklist usb-storage' #text which i want to add in the file
for sysName in $(cat systemDetails) #systemDetails is file which stores
do
ssh $sysName 'echo '$password' | sudo -S echo '$val ' >> /etc/modprobe.d/blacklist.conf'
echo
done
#script ends
NOTE: I have configured my system such that no ssh password is required.
Any pointers in this regard will be really helpful.