Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to get Ubuntu to lock and unlock itself, if a particular USB stick is attached?

For example; I sit down at my laptop; I plug the USB stick in and the system unlocks and presents itself.

I take the USB stick out, and the system locks and cannot be unlocked without that particular USB stick.

Is there any way to do this, my friends?

share|improve this question
up vote 1 down vote accepted

I don't know about any products (like Predator for Windows) but I have seen this solution which appears to work:

Use a script to loop&sleep filtering to grep for info specific to your USB stick. When you get a match, kill the screensaver.

Be sure to have the sleep timer a LOT shorter when the USB is removed than when the USB is inserted.

When you are away (USB removed) all your machine has to do is fanatically cycle through lsusb looking for your return (USB inserted).

EDIT: A working example of this to get you on your way can be found at

share|improve this answer
Yuck, it would be better to have udev trigger an event on USB insertion/removal that would read someone off the key for verification. – tgm4883 Sep 22 '11 at 19:55
Thank you, my friend! Though I have to say, I was rather hoping there was a simpler, easier program for it... Still, there's nothing like being baptised by fire when it comes to cron :P – Dante Ashton Sep 24 '11 at 10:48

Pamusb is much easier solution.

links to setup guides:
pamusb setup guide on github.
debian wiki guide on pamusb.

share|improve this answer
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Kaz Wolfe Sep 27 '14 at 0:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.