Configuring user actions (operation) logging
This guide details the procedure for enabling real-time command logging for all users accessing the management node via the Bash shell. This is a critical security and compliance step that ensures every command executed by a user is recorded centrally in the system log, preventing users from clearing their activity trail.
π― Prerequisitesβ
- Administrative (root) access to the management node.
- The
bashshell andrsyslogservice must be installed and running (standard on most Linux distributions).
Configure real-time user history loggingβ
-
Log into your cluster management shell as the
rootuser. -
Create the Bash startup file to define the logging behavior. Files in the
/etc/profile.d/directory are automatically sourced (executed) for every user upon login. -
Create and edit the file with
vi /etc/profile.d/bash_history_logging.sh. -
Enter
iand paste the following content to ensure that user history is logged after each session.export PROMPT_COMMAND='history -a >(logger -t "bash_history[$USER]")' -
Verify the pasted content is the same as above. Press the
ESC(escape) key and enter:wqto save and exit the file.
Configure System Log Handling (rsyslog)β
-
Log into your cluster management shell as the
rootuser. -
Create the rsyslog Configuration File
-
Create a new configuration file in the /etc/rsyslog.d/ directory. Files here define custom logging rules.
vi /etc/rsyslog.d/bash_history.conf -
Add the filtering rules by typing
ito insert the content. Insert the following rule into the file. This rule targets all log messages tagged with "bash_history" and writes them to a specific log file.:syslogtag, startswith, "bash_history" /var/log/messages -
Save the contents by pressing the
ESC(escape) key and entering:wqto save and exit the file. -
Restart the rsyslog Service Apply the new logging configuration by restarting the service:
systemctl restart rsyslog
Verify user operation recordsβ
-
Perform Test Operations Log in as a standard, non-root user (e.g., userA). The new configuration from /etc/profile.d/ will apply.
# Example test commands for userAdatels -l /tmpecho "Test complete" -
Review the Audit Log Log back in as root and verify that the executed commands, username, and PID have been logged in the new audit file.