This is the script used to send email when any user logged in to the Linux server.

Step 1 : Login to the server
Step 2 : vi .bash_profile
Step 3 : Copy 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`”  <mailaccount>

Step 4 : Save and exit
Step 5 : Now log out and login to the server. You will receive an mail to “hemanthpresence@gmail.com”.

Note: Change the email ID and the IP ADDRESS to yours.

Leave a Reply