LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   How can I request password when Usb hardware is plugged in? (https://www.linuxquestions.org/questions/linux-security-4/how-can-i-request-password-when-usb-hardware-is-plugged-in-936640/)

m.mancio 03-27-2012 04:39 AM

How can I request password when Usb hardware is plugged in?
 
Hi all,
at the moment I use Xubuntu 11.10, my question is:
How can I request password when Usb hardware is plugged in (usb mass storage or keyboard or other usb device)?
Example:
I plug usb mass storage: now xubuntu open a window and show me files and folders of a usb mass storage. I want that when I plug usb mass storage ask a "root/sudo" password and after show files and folder.

Thanks :-)

jv2112 03-27-2012 05:01 AM

You can use chmod to change the permissions of the mount point so that only "trusted" users can access.

-- Use Chown to set the owner to trutsed_user.Trusted_group

-- add any user to the trusted group that is needed. (usermod)

-- chmod -R 770 /media ( or whatever the mount point is and the permission you want to set )


Hope this helps.

m.mancio 03-27-2012 05:13 AM

Thanks jv2112,
but now I can't see usb mass storage...
I want that system ask me a password when I plug usb device (usb mass storage or keyboard).

catkin 03-27-2012 05:21 AM

The user must allow others to write to their X session. [[ $DISPLAY ]] && /usr/bin/xhost +localhost in ~/.bash_profile would do that.

Write a udev rule to run a script when the USB device is plugged in. Best guidance here (it's a bit outdated. udevadm has take over from some of the commands listed there).

The script can use dialog or one of its equivalents (yad is good) to interact with the user and request the password.

The script will be running as root so can do anything, including mounting the USB device and starting the file browser on the user's desktop (best to su to the user when doing that).

Those steps do everything you asked for. You probably also want to check the password given ... ?

m.mancio 03-27-2012 05:40 AM

Thanks catkin,
this night (Italian hour) I'll try your solution.
At the moment I found this:
http://ubuntuforums.org/showpost.php...79&postcount=8
Works great for usb mass storage.

catkin 03-27-2012 05:46 AM

Quote:

Originally Posted by m.mancio (Post 4637465)
Thanks catkin,
this night (Italian hour) I'll try your solution.
At the moment I found this:
http://ubuntuforums.org/showpost.php...79&postcount=8
Works great for usb mass storage.

That looks a lot simpler than my suggestion! :)


All times are GMT -5. The time now is 10:49 AM.