Lab 10: Logging and auditing

Task 1: journald

Task 2: rsyslog

Rsyslog rules typically have the facility and the level. These two combined in the form facility.level define the priority of the log message.

More about facility and level: https://success.trendmicro.com/dcx/s/solution/TP000086250

Logging rsyslog to a remote server

Task 3: Logrotate

We have a log file /var/log/lab10.log that we need to rotate periodically.

You can test and troubleshoot your logrotate configuration by running $ logrotate -s logstatus /etc/lab10-rotate.d/lab10log.
If no message is displayed on the terminal after running the command, it means that the configuration is good.
You can look in the target log file directory to verify that the log has been rotated.

Task 4: User authentication activities

Task 5: User sessions and sudo usage

Questions to answer

  1. What security monitoring tool will you forward your system logs to for security event detection? Give reasons for your choice.
  2. Configure rsyslogd by adding a rule to the newly created configuration file /etc/rsyslog.d/auth-errors.conf to log all security and authentication messages with the priority alert and higher to the /var/log/auth-errors file. Test the newly added log directive with the logger command. Verify it from rsyslog and journald perspectives by filtering the output.
  3. Install Apache web server and configure log rotate to rotate its web access log every six hours. Compress the rotated log files, and ensure that log rotate restarts the web server after rotating the logs. Manually execute the logrotate utility to test your configuration and show results.
  4. Create a bash script that continuously monitors the /var/log/auth.log file and triggers an alarm if there are three or more “authentication failure” in 30 seconds. The text Three or more authentication failure in 30 seconds should be appended to a log file /var/log/alarm.log everytime the alarm is triggered. Show test use case and results.
  5. How can you log all commands executed by every user on Linux systems. What utility will you use for this. Show how you configure this tool, and show the logs generated.

Bonus

  1. Set up a centralized journald logging server systemd-journal-remote. Configure another machine as a client to forward its journal to the logging server.
    • Test your setup by running the logger utility on the client system and show the logs generated on the logging server.