Log all bash commands to file or remote server
On CentOS 7 you can log all commands to syslog an then to local file or even to remote server.
Send all commands to syslog
Create file /etc/sysconfig/bash-prompt-xterm:
and change, to be executable:
Configure syslog to send messages from local6 facility to separate file
Create file /etc/rsyslog.d/bash.conf:
finally:
Now you can monitor commands:
Log command using audit
Alternatively you can use audit - create /etc/audit/rules.d/bash_history.rules:
but logs are not very human friendly:
and you may also want to log execvp, execl, execveat etc.
Sources:
https://askubuntu.com/questions/93566/how-to-log-all-bash-commands-by-all-users-on-a-server
https://unix.stackexchange.com/questions/86000/how-can-you-log-every-command-typed
http://whmcr.com/2011/10/14/auditd-logging-all-commands/
Komentarze
Log in or create a user account to comment.