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.

203 lines
6.3 KiB

  1. ====== Installation ======
  2. Before going ahead, be sure to follow the upgrading instructions if you're using
  3. an older version of pamusb.
  4. ===== Requirements =====
  5. * Requirements for pam_usb and pusb_check:
  6. * libpam
  7. * libhal-storage
  8. * libxml2
  9. * Requirements for pusb_hotplug and pusb_adm:
  10. * python2.4
  11. * python-celementtree
  12. * python-dbus
  13. * python-gobject
  14. ===== Installing from sources =====
  15. * Step 1: Download the latest release
  16. * Step 2: Unpack the distribution tarball
  17. $ tar -zxvf pam_usb-<version>.tar.gz
  18. $ cd pam_usb-<version>
  19. * Step 3: Compile and install
  20. $ make
  21. # make install
  22. ====== Configuring ======
  23. ===== Devices and Users =====
  24. * Copy the default configuration file to /etc/pusb/pusb.conf:
  25. cp /etc/pusb/pusb.conf-dist /etc/pusb/pusb.conf
  26. * Once you've connected your USB device to the computer, use pusb_adm to add it
  27. to the configuration file:
  28. # pusb_adm --add-device MyDevice
  29. Name : MyDevice
  30. Vendor : SanDisk Corp.
  31. Model : Cruzer Titanium
  32. Serial : SNDKXXXXXXXXXXXXXXXX
  33. Volume UUID : 6F6B-42FC (/dev/sda1)
  34. Save device to /etc/pusb/pusb.conf ?
  35. [y/n] y
  36. Done.
  37. Note that MyDevice can be any arbitrary name you'd like.
  38. If more devices are connected, pusb_adm will ask you which device you want to
  39. use.
  40. * Edit your /etc/pusb/pusb.conf config file to add the users:
  41. <users>
  42. <user id="root">
  43. <device>MyDevice</device>
  44. </user>
  45. <user id="scox">
  46. <device>MyDevice</device>
  47. </user>
  48. </users>
  49. * In order to test if everything went fine, we're gonna use the pusb_check tool
  50. which will simulate an authentication event.
  51. # pusb_check -a -u root -s su
  52. * Authentication request for user "root" (su)
  53. * Device "MyDevice" is connected (good).
  54. * Performing one time pad verification...
  55. * Verification match, updating one time pads...
  56. * Access granted.
  57. ===== PAM Module =====
  58. The PAM module pam_usb.so is used to let applications authenticate you using
  59. your USB device instead of asking your password. The default password-based
  60. authentication will be used as fallback if the device authentication goes wrong.
  61. You don't need to setup the hotplugging feature as pam_usb.so and pusb_hotplug
  62. are independent of each other.
  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 pusb.conf using
  74. 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. ===== Hotplug =====
  85. Hotplugging is a feature provided by pusb_hotplug that allows you to
  86. automatically execute commands upon locking and unlocking events. Those events
  87. are generated when you insert or remove your authentication device.
  88. For instance, you could automatically start your screensaver as soon as you
  89. remove the device, and deactivate it when you plug the device back:
  90. <user id="scox">
  91. <device>MyDevice</device>
  92. <hotplug event="lock">gnome-screensaver-command --lock</hotplug>
  93. <hotplug event="unlock">gnome-screensaver-command --deactivate</hotplug>
  94. </user>
  95. Replace gnome-screensaver-command --lock and gnome-screensaver-command --unlock
  96. with any command you want to execute. You can also execute more commands by
  97. adding extra <hotplug> entries.
  98. $ pusb_hotplug
  99. pusb_hotplug[18329]: pusb_hotplug up and running.
  100. pusb_hotplug[18329]: Watching device "MyDevice" for user "scox"
  101. pusb_hotplug[18329]: Device "MyDevice" has been removed, locking down user
  102. "scox"...
  103. pusb_hotplug[18329]: Running "gnome-screensaver-command --lock"
  104. pusb_hotplug[18329]: Locked.
  105. pusb_hotplug[18329]: Device "MyDevice" has been inserted. Performing
  106. verification...
  107. pusb_hotplug[18329]: Executing "/usr/bin/pusb_check -q -c /etc/pusb/pusb.conf -u
  108. scox -s pusb_hotplug -a"
  109. pusb_hotplug[18329]: Authentication succeeded. Unlocking user "scox"...
  110. pusb_hotplug[18329]: Running "gnome-screensaver-command --deactivate"
  111. pusb_hotplug[18329]: Unlocked.
  112. Depending on your desktop environment, you have to add pusb_hotplug to the list
  113. of autostarted applications so it will be started automatically.
  114. For instance, with GNOME:
  115. - Open System -> Preferences -> Sessions
  116. - Select Startup Programs and press Add
  117. - Enter pusb_hotplug and press OK
  118. - Press Close
  119. ====== Troubleshooting ======
  120. ===== Log Analysis =====
  121. Both pam_usb.so and pusb_hotplug use the syslog facility to log authentication
  122. attempts.
  123. This can be useful for GUI-driven applications (for instance GDM) where you
  124. don't get to see console output.
  125. Messages are logged with the AUTH facility, they are usually written to
  126. /var/log/auth.log but may vary
  127. depending on the operating system you're using.
  128. # tail -f /var/log/auth.log
  129. pusb_hotplug[25429]: Device "sandisk" has been inserted. Performing
  130. verification...
  131. pusb_hotplug[25429]: Executing "/usr/bin/pusb_check -q -c /etc/pusb/pusb.conf -u
  132. scox -s pusb_hotplug -a"
  133. pam_usb[25485]: Authentication request for user "scox" (pusb_hotplug)
  134. pam_usb[25485]: Device "sandisk" is connected (good).
  135. pam_usb[25485]: Access granted.
  136. pusb_hotplug[25429]: Authentication succeeded. Unlocking user "scox"...
  137. pusb_hotplug[25429]: Unlocked.
  138. ===== Enabling debug =====
  139. Enabling debug messages may help you find out what's wrong.
  140. To enable them, edit /etc/pusb/pusb.conf and set the following option:
  141. <defaults>
  142. <option name="debug">true</option>
  143. </defaults>
  144. If you wish, you could enable debug messages only for a specific user, device or
  145. service.
  146. For instance, if you want to enable debug messages only for the sudo service,
  147. you could do the following:
  148. <services>
  149. <service id="sudo">
  150. <option name="debug">true</option>
  151. </service>
  152. </services>
  153. ====== It works - What next ? ======
  154. * Have a look at the configuration documentation