Receive root login alerts

If you want to be notified every time when someone login into SSH as root.In this tutorial we will show you how to set email notification for root logins.
To improve the security of your a Linux server you can set up BASH so it delivers an e-mail whenever someone logs in using the root account. This is how you do it:
Edit .bash_profile (located in /root directory)

cd /root/.bash_profile

At the bottom just add the following line:

echo ‘ALERT – Root Shell Access (SERVERNAME) on:’ `date` `who` | mail -s “Alert: Root Access from `who | cut -d”(” -f2 | cut -d”)” -f1`” EMAIL

Just replace SERVERNAME with the name of your server and EMAIL with your e-mail address. The next time you login with the root account you will receive an alert e-mail.