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.

238 lines
7.1 KiB

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