A script to setup alert root login to a linux server
Follow the below steps:
1 . Login to the server as root
2. Open the file .bash_profile
vi .bash_profile
3. Paste the script below
echo ‘ALERT – Root Shell Access (root@IP ADDRESS) on:’ `date` `who` | mail -s “Alert: Root Access from `who | cut -d”(” -f2 | cut -d”)” -f1`” xyz@gmail.com
4. Save and exit by :wq!
5. Check the mail xyz@gmail.com
Note : You can change the email address xyz@gmail.com with your desired email address to set the alert.