Saturday, February 07, 2015

Email alert when SSH logged in!

cd /home/username/
nano .bashrc

Add this line last
echo 'ALERT - Root Shell Access (ServerName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d'(' -f2 | cut -d')' -f1`" your@yourdomain.com

EG:
ALERT - Root Shell Access (Database Replica) on: Thu Nov 28 16:59:40 IST 2013 tecmint pts/0 2013-11-28 16:59 (172.16.25.125)

Copied from: http://www.tecmint.com/get-root-ssh-login-email-alerts-in-linux/

No comments: