Wednesday, June 15, 2016

e-mail alert for every root logins

Script to send email for every root logins in linux


1.cd /root
2 nano .bashrc
3. 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`"yourname@gmail.com

Replace gmail with the handle for your actual server
Replace you@yourdomain.com with your actual email address

4. CTRL+x Y

now log in as root u should get the email
to check the status of mail in the linux type mailq
tail -n 50 /var/log/maillog

1 comment:

  1. Thanks its generally helpfull for me its important informations.Great Content on call center solutions

    ReplyDelete