Locking with USB drive

14,676

Solution 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

Solution 2

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:
14,676

Related videos on Youtube

Community
Author by

Community

Updated on September 18, 2022

Comments

  • Community
    Community almost 2 years

    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?

    • January
      January almost 12 years
      Can you explain what the program does?
    • SirCharlo
      SirCharlo almost 12 years
      @January You don't know about Predator? :O
    • January
      January almost 12 years
      @SirCharlo I do know about this Predator only; since I hardly ever used Windows, I can hardly know every weird little program for Windows.
    • Admin
      Admin almost 12 years
    • SirCharlo
      SirCharlo almost 12 years
      @January It ain't weird. It's awesome :)
    • Admin
      Admin almost 12 years
      GUTS GUYS GUYS . i dont want comments about how much predator is good ?
    • January
      January almost 12 years
      Why would anyone use anything like that? Escapes my comprehension.
    • Admin
      Admin almost 12 years
      if anyone is lazy to write password so he'll use it :D
    • SirCharlo
      SirCharlo almost 12 years
      @January Meh.. Lock and unlock quickly without entering a password.
    • January
      January almost 12 years
      Oh, typing deficiency, I get it (it would take me much more time to fumble with a USB stick, dig it out from my trousers pocket, putting it the right way in the USB slot... while typing the password is as good as instant)
    • Admin
      Admin almost 12 years
      those are thousands linux guys . and i think only i didnt found it @aking1012
    • pzkpfw
      pzkpfw almost 12 years
      Full disk encryption with a passphrase stored on a USB stick?
  • an offer can't refuse
    an offer can't refuse almost 12 years
    how i can find my USB ID ?
  • Branimir Kolar
    Branimir Kolar almost 12 years
    It's explained on that site in terminal "...run lsusb and locate your USB Device..."
  • an offer can't refuse
    an offer can't refuse almost 12 years
    is there any recovery when i lost my drive?
  • SirCharlo
    SirCharlo almost 12 years
    @EnesKuray Check out my last comment, under your question.
  • Branimir Kolar
    Branimir Kolar almost 12 years
    @EnesKuray you can always enter your password to login to desktop
  • an offer can't refuse
    an offer can't refuse almost 12 years
    how can i use 2 device ?