April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Unlock account in linux using pam_tally2

DESCRIPTION
This module maintains a count of attempted accesses, can reset count on
success, can deny access if too many attempts fail.

pam_tally2 comes in two parts: pam_tally2.so and pam_tally2. The former
is the PAM module and the latter, a stand-alone program. pam_tally2 is
an (optional) application which can be used to interrogate and
manipulate the counter file. It can display users’ counts, set
individual counts, or clear all counts. Setting artificially high
counts may be useful for blocking users without changing their
passwords. For example, one might find it useful to clear all counts
every midnight from a cron job.

Normally, failed attempts to access root will not cause the root
account to become blocked, to prevent denial-of-service: if your users
aren’t given shell accounts and root may only login via su or at the
machine console (not telnet/rsh, etc), this is safe.

OPTIONS
GLOBAL OPTIONS
This can be used for auth and account module types.

onerr=[fail|succeed]
If something weird happens (like unable to open the file),
return with PAM_SUCCESS if onerr=succeed is given, else with
the corresponding PAM error code.

file=/path/to/counter
File where to keep counts. Default is /var/log/tallylog.

audit
Will log the user name into the system log if the user is not
found.

silent
Don’t print informative messages.

no_log_info
Don’t log informative messages via syslog(3).

AUTH OPTIONS
Authentication phase first increments attempted login counter and
checks if user should be denied access. If the user is
authenticated and the login process continues on call to
pam_setcred(3) it resets the attempts counter.

deny=n
Deny access if tally for this user exceeds n.

lock_time=n
Always deny for n seconds after failed attempt.

unlock_time=n
Allow access after n seconds after failed attempt. If this
option is used the user will be locked out for the specified
amount of time after he exceeded his maximum allowed attempts.
Otherwise the account is locked until the lock is removed by a
manual intervention of the system administrator.

magic_root
If the module is invoked by a user with uid=0 the counter is
not incremented. The sysadmin should use this for user launched
services, like su, otherwise this argument should be omitted.

no_lock_time
Do not use the .fail_locktime field in /var/log/faillog for
this user.

even_deny_root
Root account can become unavailable.

root_unlock_time=n
This option implies even_deny_root option. Allow access after n
seconds to root account after failed attempt. If this option is
used the root user will be locked out for the specified amount
of time after he exceeded his maximum allowed attempts.

serialize
Serialize access to the tally file using locks. This option
might be used only for non-multithreaded services because it
depends on the fcntl locking of the tally file. Also it is a
good idea to use this option only in such configurations where
the time between auth phase and account or setcred phase is not
dependent on the authenticating client. Otherwise the
authenticating client will be able to prevent simultaneous
authentications by the same user by simply artificially
prolonging the time the file record lock is held.

ACCOUNT OPTIONS
Account phase resets attempts counter if the user is not magic
root. This phase can be used optionally for services which don’t
call pam_setcred(3) correctly or if the reset should be done
regardless of the failure of the account phase of other modules.

magic_root
If the module is invoked by a user with uid=0 the counter is
not changed. The sysadmin should use this for user launched
services, like su, otherwise this argument should be omitted.

Example:
To get information about when invalid login attempted
server1:/root>pam_tally2
Login Failures Latest failure From
john 12 04/01/12 10:18:35 server2

To unlock account
server1:/root>pam_tally2 -r -u john
Login Failures Latest failure From
yangw 3 05/16/13 01:06:35 pts/7

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>