Pages

Friday, November 16, 2012

How to Use your USB Flash Drive (USB Token) to Log into your PC under Ubuntu/Linux Mint

In this tutorial, we will help you create secure way for logging in with
the help of your USB stick to your session. Once setup, you will no
longer use your user account name and password to log in, just insert
your usb device and click Log In:

To do this, we will use PAMUSB which is a module for PAM (Pluggable Authentication Modules) that allows users to have authentication from a USB device. It is compatible with many display managers (LightDM, GDM, etc.).

Getting Started

Open the terminal and run this command to install required packages under Ubuntu 12.10/12.04/Linux Mint 13:

sudo apt-get install pamusb-tools libpam-usb

Connect your usb flash drive to your computer/laptop and run this
command to add it to PAM (the usb device will be detected
automatically):

sudo pamusb-conf --add-device usb-key-name

Replace usb-key-name with any name of your choice. You will be prompted to save your configuration to /etc/pamusb.conf, type Y and press Enter:

Let's now add your username to PAM so that it will be granted access to your desktop via the USB drive. To do this, run this command:

sudo pamusb-conf --add-user username

Replace username with your own user account name. Or run this command which will detect automatically your current username:

sudo pamusb-conf --add-user=$USER

Type again Y and press Enter to save:

Edit now this file to make sure PAM is using the pam_usb library:

sudo gedit /etc/pam.d/common-auth

For Linux Mint, replace gedit with pluma. These lines must be available in /etc/pam.d/common-auth: