2

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?

13
  • Can you explain what the program does?
    – January
    Sep 28, 2012 at 12:14
  • @January You don't know about Predator? :O
    – SirCharlo
    Sep 28, 2012 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, 2012 at 12:20
  • @January predator-usb.com/predator/en/index.php
    – user84277
    Sep 28, 2012 at 12:21
  • 1
    Why would anyone use anything like that? Escapes my comprehension.
    – January
    Sep 28, 2012 at 12:24

3 Answers 3

3

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.

1

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

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

You can use cuttlefish

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