How do I set up USB security key based authentication?

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?


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 http://www.techienote.com/2011/03/lock-unlock-ubuntu-desktop-using-usb-drive.html