HostOnNet Blog

E-mail Alert on Root SSH Login

Looking for Linux Server Admin or WordPress Expert? We can help.

You can get notification email when some one login to your server as root when you are using bash shell.

To enable root login notification, do the following

1. cd /root

2. edit .bashrc file with command
vi .bashrc

3. Add following content to .bashrc file

echo ‘ALERT – ServerName Root Access on:’ `date` `who` | mail -s “Alert: Root Access from `who | cut -d'(‘ -f2 | cut -d’)’ -f1`” [email protected]

Change
ServerName to your server name.
[email protected] to your email address.

4. Save and Exit vi text editor with command :wq

Now log out of SSH and login, you will get SSH Root Login alert email with IP addrss and time of login.

Posted in Windows. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.