Information
Monitor session initiation events. The parameters in this section track changes to the files associated with session events.
- /var/run/utmp - tracks all currently logged in users.
- /var/log/wtmp - file tracks logins, logouts, shutdown, and reboot events.
- /var/log/btmp - keeps track of failed login attempts and can be read by entering the command /usr/bin/last -f /var/log/btmp.
All audit records will be tagged with the identifier "session."
Monitoring these files for changes could alert a system administrator to logins occurring at unusual hours, which could indicate intruder activity (i.e. a user logging in at a time when they do not normally log in).
Solution
- Add the audit rule(s) that monitor changes to /var/run/utmp, /var/log/wtmp, and /var/log/btmp . The procedure adds each rule only for targets that exist, so augenrules --load does not error. Run:
#!/usr/bin/env bash
{
[ -e /var/run/utmp ] && printf '%s\n' "-a always,exit -S all -F path=/var/run/utmp -F perm=wa -F key=session"
[ -e /var/log/wtmp ] && printf '%s\n' "-a always,exit -S all -F path=/var/log/wtmp -F perm=wa -F key=session"
[ -e /var/log/btmp ] && printf '%s\n' "-a always,exit -S all -F path=/var/log/btmp -F perm=wa -F key=session"
} >> /etc/audit/rules.d/50-session.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