Hardware authentication for Linux using ordinary USB Flash Drives.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

227 lines
7.0 KiB

  1. ====== Quickstart ======
  2. Before going ahead, make sure to follow the upgrading instructions if you're
  3. using an older version of pam_usb.
  4. ===== Installing ====
  5. ==== Installing from sources ====
  6. * Step 1: Download the latest release
  7. * Step 2: Unpack the distribution tarball
  8. $ tar -zxvf pam_usb-<version>.tar.gz
  9. $ cd pam_usb-<version>
  10. * Step 3: Make sure that you have installed the required dependencies
  11. pam_usb depends on libxml2, PAM and HAL. pam_usb's tools (pamusb-agent,
  12. pamusb-conf) depends on python, python-celementtree and python-gobject.
  13. * Step 3: Compile and install
  14. $ make
  15. # make install
  16. ==== Installing from Subversion ====
  17. If you want to use the development version, you can fetch the sources from
  18. subversion
  19. $ svn co https:pamusb.svn.sourceforge.net/svnroot/pamusb/trunk/pam_usb
  20. ===== Setting up =====
  21. ==== Devices and Users ====
  22. * Once you've connected your USB device to the computer, use pamusb-conf to add
  23. it to the configuration file:
  24. # pamusb-conf --add-device MyDevice
  25. Please select the device you wish to add.
  26. * Using "SanDisk Corp. Cruzer Titanium (SNDKXXXXXXXXXXXXXXXX)" (only option)
  27. Which volume would you like to use for storing data ?
  28. * Using "/dev/sda1 (UUID: <6F6B-42FC>)" (only option)
  29. Name : MyDevice
  30. Vendor : SanDisk Corp.
  31. Model : Cruzer Titanium
  32. Serial : SNDKXXXXXXXXXXXXXXXX
  33. Volume UUID : 6F6B-42FC (/dev/sda1)
  34. Save to /etc/pamusb.conf ?
  35. [Y/n] y
  36. Done.
  37. Note that MyDevice can be any arbitrary name you'd like. Also, you can add as
  38. many devices as you want.
  39. * Users
  40. Now that we have added the devices, we have to configure the users.
  41. # pamusb-conf --add-user root
  42. Which device would you like to use for authentication ?
  43. * Using "MyDevice" (only option)
  44. User : root
  45. Device : MyDevice
  46. Save to /etc/pamusb.conf ?
  47. [Y/n] y
  48. Done.
  49. Repeat this step for every other username you'd like to use pam_usb with (e.g.
  50. pamusb-conf --add-user MyUsername).
  51. * In order to check if everything went fine, we are going to use the
  52. pamusb-check tool which will simulate an authentication event.
  53. # pamusb-check root
  54. * Authentication request for user "root" (pamusb-check)
  55. * Device "MyDevice" is connected (good).
  56. * Performing one time pad verification...
  57. * Verification match, updating one time pads...
  58. * Access granted.
  59. ==== PAM Module ====
  60. The PAM module pam_usb.so is used to let applications authenticate you using
  61. your USB device instead of asking your password. The default password-based
  62. authentication will be used as fallback if the device authentication goes wrong.
  63. * Depending on the operating system you're using, you have to tell PAM to use
  64. pam_usb.so as default authentication method. There should be a file named
  65. either common-auth (Gentoo) under /etc/pam.d/. If you do NOT have neither of
  66. those files, you'll have to edit each pam.d service file you want to use (e.g.
  67. /etc/pam.d/su, /etc/pam.d/gdm and so on).
  68. * Locate the following line on /etc/pam.d/common-auth or /etc/pam.d/system-auth:
  69. auth required pam_unix.so nullok_secure
  70. * And change it to look something like that:
  71. auth sufficient pam_usb.so
  72. auth required pam_unix.so nullok_secure
  73. * You should now be able to authenticate the users configured in pamusb.conf
  74. using your USB device:
  75. scox $ su
  76. * pam_usb v.SVN
  77. * Authentication request for user "root" (su)
  78. * Device "MyDevice" is connected (good).
  79. * Performing one time pad verification...
  80. * Verification match, updating one time pads...
  81. * Access granted.
  82. * Try to authenticate to a different application. pam_usb.so should work with
  83. any application using xscreensaver and many more).
  84. ==== Agent ====
  85. The pam_usb agent (pamusb-agent) allows you to automatically execute commands
  86. upon locking and unlocking events. Those events are generated when you insert or
  87. remove your authentication device.
  88. To configure the commands, you have to edit pam_usb's configuration file
  89. (/etc/pamusb.conf) and add agent entries into your user section.
  90. For instance, you could automatically start your screensaver as soon as you
  91. remove the device, and deactivate it when you plug the device back.
  92. * GNOME (gnome-screensaver):
  93. <user id="scox">
  94. <device>MyDevice</device>
  95. <agent event="lock">gnome-screensaver-command --lock</agent>
  96. <agent event="unlock">gnome-screensaver-command --deactivate</agent>
  97. </user>
  98. * KDE (kscreensaver):
  99. <user id="scox">
  100. <device>MyDevice</device>
  101. <agent event="lock">dcop kdesktop KScreensaverIface lock</agent>
  102. <agent event="unlock">dcop kdesktop KScreensaverIface quit</agent>
  103. </user>
  104. You can execute more commands by adding extra <agent> entries.
  105. $ pamusb-agent
  106. pamusb-agent[18329]: pamusb-agent up and running.
  107. pamusb-agent[18329]: Watching device "MyDevice" for user "scox"
  108. pamusb-agent[18329]: Device "MyDevice" has been removed, locking down user
  109. "scox"...
  110. pamusb-agent[18329]: Running "gnome-screensaver-command --lock"
  111. pamusb-agent[18329]: Locked.
  112. pamusb-agent[18329]: Device "MyDevice" has been inserted. Performing
  113. verification...
  114. pamusb-agent[18329]: Executing "/usr/bin/pamusb-check --quiet
  115. --config=/etc/pamusb.conf --service=pamusb-agent scox"
  116. pamusb-agent[18329]: Authentication succeeded. Unlocking user "scox"...
  117. pamusb-agent[18329]: Running "gnome-screensaver-command --deactivate"
  118. pamusb-agent[18329]: Unlocked.
  119. Depending on your desktop environment, you have to add pamusb-agent to the list
  120. of autostarted applications so it will be started automatically.
  121. * GNOME:
  122. - Open System -> Preferences -> Sessions
  123. - Select Startup Programs and press Add
  124. - Enter pamusb-agent and press OK
  125. - Press Close
  126. * KDE:
  127. - cd ~/.kde/Autostart
  128. - ln -s /usr/bin/pamusb-agent pamusb-agent
  129. ===== Troubleshooting =====
  130. ==== Log Analysis ====
  131. Both pam_usb.so and pamusb-agent use the syslog facility to log authentication
  132. attempts.
  133. This can be useful for GUI-driven applications (for instance GDM) where you
  134. don't get to see console output.
  135. Messages are logged with the AUTH facility, they are usually written to
  136. /var/log/auth.log but may vary
  137. depending on the operating system you're using.
  138. # tail -f /var/log/auth.log
  139. pamusb-agent[25429]: Device "sandisk" has been inserted. Performing
  140. verification...
  141. pamusb-agent[25429]: Executing "/usr/bin/pamusb-check --quiet
  142. --config=/etc/pamusb.conf --service=pamusb-agent scox"
  143. pam_usb[25485]: Authentication request for user "scox" (pamusb-agent)
  144. pam_usb[25485]: Device "sandisk" is connected (good).
  145. pam_usb[25485]: Access granted.
  146. pamusb-agent[25429]: Authentication succeeded. Unlocking user "scox"...
  147. pamusb-agent[25429]: Unlocked.
  148. ==== Enabling debug ====
  149. Enabling debug messages may help you find out what's wrong.
  150. To enable them, edit /etc/pamusb.conf and set the following option:
  151. <defaults>
  152. <option name="debug">true</option>
  153. </defaults>
  154. If you wish, you could enable debug messages only for a specific user, device or
  155. service.
  156. For instance, if you want to enable debug messages only for the sudo service,
  157. you could do the following:
  158. <services>
  159. <service id="sudo">
  160. <option name="debug">true</option>
  161. </service>
  162. </services>
  163. ===== It works - What next ? =====
  164. * Have a look at the configuration documentation