Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Possible Duplicate:
Lock and Unlock from USB disk (pendrive)

When i use Windows, there is a program I use called Predator that locks my PC when I remove a certain USB flash drive. It then unlocks the computer when I reinsert it.

Is there any program like this for Ubuntu?

share|improve this question

marked as duplicate by SirCharlo, jokerdino, January, Mitch, TheX Sep 28 '12 at 13:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Can you explain what the program does? –  January Sep 28 '12 at 12:14
    
@January You don't know about Predator? :O –  SirCharlo Sep 28 '12 at 12:17
3  
@SirCharlo I do know about this Predator only; since I hardly ever used Windows, I can hardly know every weird little program for Windows. –  January Sep 28 '12 at 12:20
    
@January predator-usb.com/predator/en/index.php –  user84277 Sep 28 '12 at 12:21
1  
Why would anyone use anything like that? Escapes my comprehension. –  January Sep 28 '12 at 12:24
show 8 more comments

3 Answers 3

up vote 1 down vote accepted

Don't know of any program but you can create a simple script that can do that like in this example:

http://www.techienote.com/2011/03/lock-unlock-ubuntu-desktop-using-usb-drive.html

share|improve this answer
    
how i can find my USB ID ? –  user84277 Sep 28 '12 at 12:36
    
It's explained on that site in terminal "...run lsusb and locate your USB Device..." –  Branimir Kolar Sep 28 '12 at 12:38
    
is there any recovery when i lost my drive? –  user84277 Sep 28 '12 at 12:39
    
@EnesKuray Check out my last comment, under your question. –  SirCharlo Sep 28 '12 at 12:42
    
@EnesKuray you can always enter your password to login to desktop –  Branimir Kolar Sep 28 '12 at 12:53
show 1 more comment

Well, a module called PAM (Pluggable Authentication module) can be customized to achieve your need. A beautiful article is available on linuxconfig describing this in detail.

The steps are:

  1. Install PAM

    $ sudo apt-get install pamusb-tools libpam-usb
    
  2. Add USB device to PAM config

    $ sudo pamusb-conf --add-device <my-usb-stick>
    
  3. Select your volume and "Y" to save

  4. Define user for PAM auth

    $ sudo pamusb-conf --add-user <ubuntu-user>
    
  5. Select and "Y" to save

  6. Configure PAM

    $ sudo gedit /etc/pam.d/common-auth
    
  7. Add the line below and save

    auth    sufficient      pam_usb.so
    
  8. Test the PAM auth

    $ su ubuntu-user
    
  9. Lock when disconnected

    $ sudo gedit /etc/pamusb.conf
    
  10. Modify the block "user" block to look like:

    <user id="ubuntu-user"> 
          <device> 
                  my-usb-stick 
          </device> 
          <agent event="lock">gnome-screensaver-command -l</agent> 
          <agent event="unlock">gnome-screensaver-command -d</agent> 
     </user>*
    

cuttlefish could be one solution to do it as @maythux suggested. I really can't comment on its capabilities, I prefer to stay away from 3rd party apps as much as possible.

share|improve this answer
add comment

You can use cuttlefish

It does what you need plus more advanced options see this link to learn about

share|improve this answer
add comment