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.

243 lines
7.4 KiB

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