It is company policy for admins to login to the servers via a personal username, and then run sudo -i
to become root. Upon running sudo -i
, sudo will create an environmental variable called SUDO_USER
, which contains the original user's username.
Is there a way to log ALL commands within syslog with something akin to the following syntax:
${TIME/DATE STAMP}: [${REAL_USER}|${SUDO_USER}]: ${CMD}
An example entry would be:
Sat Jan 19 22:28:46 CST 2013: [root|ksoviero]: yum install random-pkg
Obviously it doesn't have to be exactly the above syntax, it just has to include a minimum of the real user (eg. root), the sudo user (eg. ksoviero), and the full command that was run (eg. yum install random-pkg).
I've already tried snoopy
, but it did not include the SUDO_USER
variable.