Server Administration & Management

How to Email Alert on Root SSH Login

If you want to receive email alert when someone makes a root login to the Server.

1. open the file /root/.bashrc

# vi /root/.bashrc

2. Scroll to the end of the file then add the following:

echo ‘ALERT – Root Shell Access (YourserverName) on:’ `date` `who` | mail -s “Alert: Root Access from `who | cut -d'(‘ -f2 | cut -d’)’ -f1`” you@yourdomain.com

September 10, 2011 Posted by | Mail, Security, SSH, Tips & Tricks | , , , , | 1 Comment