Thursday, February 17, 2011

mail alert for root login

Paste the below in either .bashrc or .bash_profile and restart your terminal


echo 'ALERT - Root Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1` to `/sbin/ifconfig | grep "inet addr" | head -1 | awk '{print $2}' | cut -d":" -f2`" user@examples.com

No comments:

Post a Comment