Information
Monitor login and logout events. The parameters below track changes to files associated with login/logout events.
- /var/log/lastlog - maintain records of the last time a user successfully logged in.
- /var/run/faillock - directory maintains records of login failures via the pam_faillock module.
Monitoring login/logout events could provide a system administrator with information associated with brute force attacks against user logins.
Solution
- Add the audit rule(s) that monitor changes to /var/log/lastlog and /var/run/faillock . The procedure adds each rule only for targets that exist, so augenrules --load does not error. Run:
#!/usr/bin/env bash
{
[ -e /var/log/lastlog ] && printf '%s\n' "-a always,exit -S all -F path=/var/log/lastlog -F perm=wa -F key=logins"
[ -e /var/run/faillock ] && printf '%s\n' "-a always,exit -S all -F path=/var/run/faillock -F perm=wa -F key=logins"
} >> /etc/audit/rules.d/50-login.rules
- Merge and load the rules into active configuration:
# augenrules --load
- Check if reboot is required:
# if [[ $(auditctl -s | grep "enabled") =~ "2" ]]; then printf "Reboot required to load rules\n"; fi