LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices



Reply
 
Search this Thread
Old 03-27-2012, 05:39 AM   #1
m.mancio
LQ Newbie
 
Registered: Oct 2009
Posts: 11

Rep: Reputation: 0
Question 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 :-)

Last edited by m.mancio; 03-27-2012 at 06:14 AM.
 
Old 03-27-2012, 06:01 AM   #2
jv2112
Member
 
Registered: Jan 2009
Location: New England
Distribution: Arch Linux
Posts: 719

Rep: Reputation: 103Reputation: 103
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.
 
Old 03-27-2012, 06:13 AM   #3
m.mancio
LQ Newbie
 
Registered: Oct 2009
Posts: 11

Original Poster
Rep: Reputation: 0
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).
 
Old 03-27-2012, 06:21 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
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 ... ?
 
Old 03-27-2012, 06:40 AM   #5
m.mancio
LQ Newbie
 
Registered: Oct 2009
Posts: 11

Original Poster
Rep: Reputation: 0
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.
 
Old 03-27-2012, 06:46 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
Quote:
Originally Posted by m.mancio View Post
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!
 
  


Reply

Tags
password, usb


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Process crash while it reads write on the USB HDD and USB is plugged out. nitinarora Linux - Kernel 4 05-18-2009 04:37 AM
How to detect programatically if a USB device is is plugged-in / plugged out? franc Linux - Software 3 02-01-2007 05:01 AM
Un-plugged PS/2 mouse then plugged it into usb. mouse now dead deathman Mandriva 2 11-20-2006 08:35 AM
not recognizing hardware is plugged in zerogood Linux - Hardware 4 09-03-2004 05:33 AM


All times are GMT -5. The time now is 11:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration