pam_faillock.8 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. '\" t
  2. .\" Title: pam_faillock
  3. .\" Author: [see the "AUTHOR" section]
  4. .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
  5. .\" Date: 09/03/2021
  6. .\" Manual: Linux-PAM Manual
  7. .\" Source: Linux-PAM Manual
  8. .\" Language: English
  9. .\"
  10. .TH "PAM_FAILLOCK" "8" "09/03/2021" "Linux-PAM Manual" "Linux\-PAM Manual"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. pam_faillock \- Module counting authentication failures during a specified interval
  32. .SH "SYNOPSIS"
  33. .HP \w'\fBauth\ \&.\&.\&.\ pam_faillock\&.so\fR\ 'u
  34. \fBauth \&.\&.\&. pam_faillock\&.so\fR {preauth|authfail|authsucc} [conf=\fI/path/to/config\-file\fR] [dir=\fI/path/to/tally\-directory\fR] [even_deny_root] [deny=\fIn\fR] [fail_interval=\fIn\fR] [unlock_time=\fIn\fR] [root_unlock_time=\fIn\fR] [admin_group=\fIname\fR] [audit] [silent] [no_log_info]
  35. .HP \w'\fBaccount\ \&.\&.\&.\ pam_faillock\&.so\fR\ 'u
  36. \fBaccount \&.\&.\&. pam_faillock\&.so\fR [dir=\fI/path/to/tally\-directory\fR] [no_log_info]
  37. .SH "DESCRIPTION"
  38. .PP
  39. This module maintains a list of failed authentication attempts per user during a specified interval and locks the account in case there were more than
  40. \fIdeny\fR
  41. consecutive failed authentications\&.
  42. .PP
  43. Normally, failed attempts to authenticate
  44. \fIroot\fR
  45. will
  46. \fBnot\fR
  47. cause the root account to become blocked, to prevent denial\-of\-service: if your users aren\*(Aqt given shell accounts and root may only login via
  48. \fBsu\fR
  49. or at the machine console (not telnet/rsh, etc), this is safe\&.
  50. .SH "OPTIONS"
  51. .PP
  52. \fB{preauth|authfail|authsucc}\fR
  53. .RS 4
  54. This argument must be set accordingly to the position of this module instance in the PAM stack\&.
  55. .sp
  56. The
  57. \fIpreauth\fR
  58. argument must be used when the module is called before the modules which ask for the user credentials such as the password\&. The module just examines whether the user should be blocked from accessing the service in case there were anomalous number of failed consecutive authentication attempts recently\&. This call is optional if
  59. \fIauthsucc\fR
  60. is used\&.
  61. .sp
  62. The
  63. \fIauthfail\fR
  64. argument must be used when the module is called after the modules which determine the authentication outcome, failed\&. Unless the user is already blocked due to previous authentication failures, the module will record the failure into the appropriate user tally file\&.
  65. .sp
  66. The
  67. \fIauthsucc\fR
  68. argument must be used when the module is called after the modules which determine the authentication outcome, succeeded\&. Unless the user is already blocked due to previous authentication failures, the module will then clear the record of the failures in the respective user tally file\&. Otherwise it will return authentication error\&. If this call is not done, the pam_faillock will not distinguish between consecutive and non\-consecutive failed authentication attempts\&. The
  69. \fIpreauth\fR
  70. call must be used in such case\&. Due to complications in the way the PAM stack can be configured it is also possible to call
  71. \fIpam_faillock\fR
  72. as an account module\&. In such configuration the module must be also called in the
  73. \fIpreauth\fR
  74. stage\&.
  75. .RE
  76. .PP
  77. \fBconf=/path/to/config\-file\fR
  78. .RS 4
  79. Use another configuration file instead of the default
  80. /etc/security/faillock\&.conf\&.
  81. .RE
  82. .PP
  83. The options for configuring the module behavior are described in the
  84. \fBfaillock.conf\fR(5)
  85. manual page\&. The options specified on the module command line override the values from the configuration file\&.
  86. .SH "MODULE TYPES PROVIDED"
  87. .PP
  88. The
  89. \fBauth\fR
  90. and
  91. \fBaccount\fR
  92. module types are provided\&.
  93. .SH "RETURN VALUES"
  94. .PP
  95. PAM_AUTH_ERR
  96. .RS 4
  97. An invalid option was given, the module was not able to retrieve the user name, no valid counter file was found, or too many failed logins\&.
  98. .RE
  99. .PP
  100. PAM_BUF_ERR
  101. .RS 4
  102. Memory buffer error\&.
  103. .RE
  104. .PP
  105. PAM_CONV_ERR
  106. .RS 4
  107. The conversation method supplied by the application failed to obtain the username\&.
  108. .RE
  109. .PP
  110. PAM_INCOMPLETE
  111. .RS 4
  112. The conversation method supplied by the application returned PAM_CONV_AGAIN\&.
  113. .RE
  114. .PP
  115. PAM_SUCCESS
  116. .RS 4
  117. Everything was successful\&.
  118. .RE
  119. .PP
  120. PAM_IGNORE
  121. .RS 4
  122. User not present in passwd database\&.
  123. .RE
  124. .SH "NOTES"
  125. .PP
  126. Configuring options on the module command line is not recommend\&. The
  127. /etc/security/faillock\&.conf
  128. should be used instead\&.
  129. .PP
  130. The setup of
  131. \fIpam_faillock\fR
  132. in the PAM stack is different from the
  133. \fIpam_tally2\fR
  134. module setup\&.
  135. .PP
  136. Individual files with the failure records are created as owned by the user\&. This allows
  137. \fBpam_faillock\&.so\fR
  138. module to work correctly when it is called from a screensaver\&.
  139. .PP
  140. Note that using the module in
  141. \fBpreauth\fR
  142. without the
  143. \fBsilent\fR
  144. option specified in
  145. /etc/security/faillock\&.conf
  146. or with
  147. \fIrequisite\fR
  148. control field leaks an information about existence or non\-existence of a user account in the system because the failures are not recorded for the unknown users\&. The message about the user account being locked is never displayed for non\-existing user accounts allowing the adversary to infer that a particular account is not existing on a system\&.
  149. .SH "EXAMPLES"
  150. .PP
  151. Here are two possible configuration examples for
  152. /etc/pam\&.d/login\&. They make
  153. \fIpam_faillock\fR
  154. to lock the account after 4 consecutive failed logins during the default interval of 15 minutes\&. Root account will be locked as well\&. The accounts will be automatically unlocked after 20 minutes\&.
  155. .PP
  156. In the first example the module is called only in the
  157. \fIauth\fR
  158. phase and the module does not print any information about the account being blocked by
  159. \fIpam_faillock\fR\&. The
  160. \fIpreauth\fR
  161. call can be added to tell users that their logins are blocked by the module and also to abort the authentication without even asking for password in such case\&.
  162. .PP
  163. /etc/security/faillock\&.conf
  164. file example:
  165. .sp
  166. .if n \{\
  167. .RS 4
  168. .\}
  169. .nf
  170. deny=4
  171. unlock_time=1200
  172. silent
  173. .fi
  174. .if n \{\
  175. .RE
  176. .\}
  177. .PP
  178. /etc/pam\&.d/config file example:
  179. .sp
  180. .if n \{\
  181. .RS 4
  182. .\}
  183. .nf
  184. auth required pam_securetty\&.so
  185. auth required pam_env\&.so
  186. auth required pam_nologin\&.so
  187. # optionally call: auth requisite pam_faillock\&.so preauth
  188. # to display the message about account being locked
  189. auth [success=1 default=bad] pam_unix\&.so
  190. auth [default=die] pam_faillock\&.so authfail
  191. auth sufficient pam_faillock\&.so authsucc
  192. auth required pam_deny\&.so
  193. account required pam_unix\&.so
  194. password required pam_unix\&.so shadow
  195. session required pam_selinux\&.so close
  196. session required pam_loginuid\&.so
  197. session required pam_unix\&.so
  198. session required pam_selinux\&.so open
  199. .fi
  200. .if n \{\
  201. .RE
  202. .\}
  203. .PP
  204. In the second example the module is called both in the
  205. \fIauth\fR
  206. and
  207. \fIaccount\fR
  208. phases and the module informs the authenticating user when the account is locked if
  209. \fBsilent\fR
  210. option is not specified in the
  211. faillock\&.conf\&.
  212. .sp
  213. .if n \{\
  214. .RS 4
  215. .\}
  216. .nf
  217. auth required pam_securetty\&.so
  218. auth required pam_env\&.so
  219. auth required pam_nologin\&.so
  220. auth required pam_faillock\&.so preauth
  221. # optionally use requisite above if you do not want to prompt for the password
  222. # on locked accounts
  223. auth sufficient pam_unix\&.so
  224. auth [default=die] pam_faillock\&.so authfail
  225. auth required pam_deny\&.so
  226. account required pam_faillock\&.so
  227. # if you drop the above call to pam_faillock\&.so the lock will be done also
  228. # on non\-consecutive authentication failures
  229. account required pam_unix\&.so
  230. password required pam_unix\&.so shadow
  231. session required pam_selinux\&.so close
  232. session required pam_loginuid\&.so
  233. session required pam_unix\&.so
  234. session required pam_selinux\&.so open
  235. .fi
  236. .if n \{\
  237. .RE
  238. .\}
  239. .SH "FILES"
  240. .PP
  241. /var/run/faillock/*
  242. .RS 4
  243. the files logging the authentication failures for users
  244. .RE
  245. .PP
  246. /etc/security/faillock\&.conf
  247. .RS 4
  248. the config file for pam_faillock options
  249. .RE
  250. .SH "SEE ALSO"
  251. .PP
  252. \fBfaillock\fR(8),
  253. \fBfaillock.conf\fR(5),
  254. \fBpam.conf\fR(5),
  255. \fBpam.d\fR(5),
  256. \fBpam\fR(8)
  257. .SH "AUTHOR"
  258. .PP
  259. pam_faillock was written by Tomas Mraz\&.