Sunday 25 May 2014

Send Users Commands typed in the SHELL to Syslog

# cd /etc

# vi profile

Add the lines below:
function history_to_syslog
{
        declare command
        command=$(fc -ln -0)
        if [ "$command" != "$old_command" ]; then
                logger -p local1.notice -t bash -i -- $USER : "$command"
        fi
        old_command=$command
}
trap history_to_syslog DEBUG


# vi rsyslog.conf

Add the lines below:
# Logging users BASH commands to syslog
local1.notice                                           /var/log/cmd.log

By Renato

No comments:

Post a Comment