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.

240 lines
8.7 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 | An 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 |
  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. </agent>
  114. <agent event="lock">
  115. <cmd>beep-media-player --pause</cmd>
  116. </agent>
  117. <!-- Resume operations when the usb device is plugged back and authenticated -->
  118. <agent event="unlock">
  119. <env>DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus</env>
  120. <env>HOME=/home/scox</env>
  121. <cmd>gnome-screensaver-command --deactivate</cmd>
  122. </agent>
  123. <agent event="unlock">
  124. <cmd>beep-media-player --play</cmd>
  125. </agent>
  126. </user>
  127. ```
  128. ----------
  129. ## Services
  130. | Name | Type | Description | Example |
  131. |------|-----------|---------------------|---------|
  132. | `id` | Attribute | Name of the service | `su` |
  133. ### Example:
  134. ```xml
  135. <service id="su">
  136. <!--
  137. Here you can put service specific options such as "enable", "debug" etc.
  138. See the options section of this document.
  139. -->
  140. </service>
  141. ```
  142. ----------
  143. Location of the configuration file
  144. ----------------------------------
  145. By default, `pam_usb.so` and its tools will look for the configuration file at `/etc/security/pam_usb.conf`.
  146. If you want to use a different location, you will have to use the `-c` flag.
  147. ```
  148. # /etc/pam.d/system-auth
  149. auth sufficient pam_usb.so -c /some/other/path.conf
  150. auth required pam_unix.so nullok_secure
  151. ```
  152. You will also have to use the `-c` option when calling pam_usb's tools.
  153. ```
  154. pamusb-agent -c /some/other/path.conf
  155. ```
  156. Example configuration
  157. ----------------------------------
  158. **NOTE**: For detailed information, rely on repository wiki pages.
  159. * **1)** Insert an USB block device
  160. * **2)** Add necessary user configuration into `/etc/security/pam_usb.conf` by running:
  161. ```
  162. sudo pamusb-conf --add-user=<username>
  163. ```
  164. where `<username>` is a valid Unix user name.
  165. * **3)** Add necessary device configuration into `/etc/security/pam_usb.conf` by running:
  166. ```
  167. sudo pamusb-conf --add-device=<devicename>
  168. ```
  169. where `<devicename>` is a recognizable name for your device. This value is only used internally in the configuration file as device `id` value.
  170. * **4)** Tweak `/etc/security/pam_usb.conf` manually as desired. Link devices and users, etc.
  171. **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`.
  172. If you use one time pads, you need to do the following:
  173. * **5)** Manually mount USB block device partition. You need write access to the mounted partition.
  174. * **6)** Run `/usr/bin/pamusb-check --debug --service=pamusb-agent <username>`
  175. where `<username>` is associated with the USB block device.
  176. By default, this command creates directory `$HOME/.pamusb/` with a protected device-associated `.pad` file. If you format the device, you must
  177. 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.
  178. * **7)** Unmount the USB block device.
  179. * **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.
  180. * **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.