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.

244 lines
8.9 KiB

  1. Configuration file reference
  2. ============================
  3. The configuration file is formatted in XML and subdivided in 4 sections:
  4. * Default options, shared among every device, user and service
  5. * Devices declaration and settings
  6. * Users declaration and settings
  7. * Services declaration and settings
  8. The syntax is the following:
  9. ```xml
  10. <configuration>
  11. <defaults>
  12. <!-- default options -->
  13. </defaults>
  14. <devices>
  15. <!-- devices definitions -->
  16. </devices>
  17. <users>
  18. <!-- users definitions -->
  19. </users>
  20. <services>
  21. <!-- services definitions -->
  22. </services>
  23. </configuration>
  24. ```
  25. ----------
  26. ## Options
  27. | Name | Type | Default | Description |
  28. |------------------------|---------|---------------------|--------------------------------------------------------------|
  29. | `enable` | Boolean | `true` | Enable pam_usb |
  30. | `debug` | Boolean | `false` | Enable debug messages |
  31. | `quiet` | Boolean | `false` | Quiet mode |
  32. | `color_log` | Boolean | `true` | Enable colored output |
  33. | `one_time_pad` | Boolean | `true` | Enable the use of one time device-associated pad files |
  34. | `deny_remote` | Boolean | `true` | Deny access from remote host (SSH) |
  35. | `probe_timeout` | Time | `10s` | Time to wait for the volume to be detected |
  36. | `pad_expiration` | Time | `1h` | Time between pad file regeneration |
  37. | `hostname` | String | Computer's hostname | Must be unique accross computers using the same device |
  38. | `system_pad_directory` | String | `.pamusb` | Relative path to the user's home used to store one time pads |
  39. | `device_pad_directory` | String | `.pamusb` | Relative path to the device used to store one time pad files |
  40. ### Example:
  41. ```xml
  42. <configuration>
  43. <defaults>
  44. <!-- Disable colored output by default -->
  45. <option name="color_log">false</option>
  46. <!-- Enable debug output -->
  47. <option name="debug">true</option>
  48. </defaults>
  49. <users>
  50. <user id="root">
  51. <!-- Enable colored output for user "root" -->
  52. <option name="color_log">true</option>
  53. </user>
  54. <user id="scox">
  55. <!-- Disable debug output for user "scox" -->
  56. <option name="debug">false</option>
  57. </user>
  58. </users>
  59. <devices>
  60. <device id="mydevice">
  61. <!-- Wait 15 seconds instead of the default 10 seconds for "mydevice" to be detected -->
  62. <option name="probe_timeout">15</option>
  63. </device>
  64. </devices>
  65. <services>
  66. <service id="su">
  67. <!-- Disable pam_usb for "su" ("su" will ask for a password as usual) -->
  68. <option name="enable">false<option>
  69. </service>
  70. </services>
  71. </configuration>
  72. ```
  73. ----------
  74. ## Devices
  75. | Name | Type | Description | Example |
  76. |---------------|-----------|------------------------------------------------|------------------------|
  77. | `id` | Attribute | Arbitrary device name | `MyDevice` |
  78. | `vendor` | Element | Device's vendor name | `SanDisk Corp.` |
  79. | `model` | Element | Device's model name | `Cruzer Titanium` |
  80. | `serial` | Element | Serial number of the device | `SNDKXXXXXXXXXXXXXXXX` |
  81. | `volume_uuid` | Element | UUID of the device's volume used to store pads | `6F6B-42FC` |
  82. ### Example:
  83. ```xml
  84. <device id="MyDevice">
  85. <vendor>SanDisk Corp.</vendor>
  86. <model>Cruzer Titanium</model>
  87. <serial>SNDKXXXXXXXXXXXXXXXX</serial>
  88. <volume_uuid>6F6B-42FC</volume_uuid>
  89. </device>
  90. ```
  91. ----------
  92. ## Users
  93. | Name | Type | Description | Example |
  94. |----------|-----------|-------------------------------------------|------------|
  95. | `id` | Attribute | Login of the user | `root` |
  96. | `device` | Attribute | `id` of the device associated to the user | `MyDevice` |
  97. | `agent` | Element | Agent commands, for use with pamusb-agent | |
  98. ### Agent
  99. | Name | Type | Description |
  100. |-------|-----------|-----------------------------------------------------------------------------------------------------------------|
  101. | `env` | Attribute | Environment variable for the command. For multiple environment variables use multiple `env` tags. |
  102. | `cmd` | Attribute | Agent command, associated with `env` tags in the same agent element. Multiple/chained `cmd` elements supported. |
  103. ### Example:
  104. ```xml
  105. <user id="scox">
  106. <device>MyDevice</device>
  107. <!-- When the user "scox" removes the usb device, lock the screen and pause
  108. beep-media-player -->
  109. <agent event="lock">
  110. <env>DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus</env>
  111. <env>HOME=/home/scox</env>
  112. <cmd>gnome-screensaver-command --lock</cmd>
  113. <cmd>sleep 5</cmd>
  114. <cmd>pkill -SIGSTOP -u 1000</cmd>
  115. </agent>
  116. <agent event="lock">
  117. <cmd>beep-media-player --pause</cmd>
  118. </agent>
  119. <!-- Resume operations when the usb device is plugged back and authenticated -->
  120. <agent event="unlock">
  121. <env>DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus</env>
  122. <env>HOME=/home/scox</env>
  123. <cmd>pkill -SIGCONT -u 1000</cmd>
  124. <cmd>sleep 5</cmd>
  125. <cmd>gnome-screensaver-command --deactivate</cmd>
  126. </agent>
  127. <agent event="unlock">
  128. <cmd>beep-media-player --play</cmd>
  129. </agent>
  130. </user>
  131. ```
  132. ----------
  133. ## Services
  134. | Name | Type | Description | Example |
  135. |------|-----------|---------------------|---------|
  136. | `id` | Attribute | Name of the service | `su` |
  137. ### Example:
  138. ```xml
  139. <service id="su">
  140. <!--
  141. Here you can put service specific options such as "enable", "debug" etc.
  142. See the options section of this document.
  143. -->
  144. </service>
  145. ```
  146. ----------
  147. Location of the configuration file
  148. ----------------------------------
  149. By default, `pam_usb.so` and its tools will look for the configuration file at `/etc/security/pam_usb.conf`.
  150. If you want to use a different location, you will have to use the `-c` flag.
  151. ```
  152. # /etc/pam.d/system-auth
  153. auth sufficient pam_usb.so -c /some/other/path.conf
  154. auth required pam_unix.so nullok_secure
  155. ```
  156. You will also have to use the `-c` option when calling pam_usb's tools.
  157. ```
  158. pamusb-agent -c /some/other/path.conf
  159. ```
  160. Example configuration
  161. ----------------------------------
  162. **NOTE**: For detailed information, rely on repository wiki pages.
  163. * **1)** Insert an USB block device
  164. * **2)** Add necessary user configuration into `/etc/security/pam_usb.conf` by running:
  165. ```
  166. sudo pamusb-conf --add-user=<username>
  167. ```
  168. where `<username>` is a valid Unix user name.
  169. * **3)** Add necessary device configuration into `/etc/security/pam_usb.conf` by running:
  170. ```
  171. sudo pamusb-conf --add-device=<devicename>
  172. ```
  173. where `<devicename>` is a recognizable name for your device. This value is only used internally in the configuration file as device `id` value.
  174. * **4)** Tweak `/etc/security/pam_usb.conf` manually as desired. Link devices and users, etc.
  175. **NOTE**: If you don't want to use one time pad files, consider setting `one_time_pad` option to `false`. Pad file use defaults to `true`.
  176. If you use one time pads, you need to do the following:
  177. * **5)** Manually mount USB block device partition. You need write access to the mounted partition.
  178. * **6)** Run `/usr/bin/pamusb-check --debug --service=pamusb-agent <username>`
  179. where `<username>` is associated with the USB block device.
  180. By default, this command creates directory `$HOME/.pamusb/` with a protected device-associated `.pad` file. If you format the device, you must
  181. delete `$HOME/.pamusb/<devicename>.pad` file. The created `.pad` file can't be used with a new partition UUIDs for the same or any USB block device.
  182. * **7)** Unmount the USB block device.
  183. * **8)** Add proper PAM configuration into `/etc/pam.d/system-auth` as described above. For testing purposes, it's highly recommended to start with `sufficient` PAM option before possibly moving to `required` or `requisite` option since you can bypass faulty `pam_usb` configurations.
  184. * **9)** Test the device/user configuration by running `sudo echo "pam_usb test"`. The USB block device must be attached (mount not required) and the user must have proper configuration in `/etc/security/pam_usb.conf` file.