Sunday, July 27, 2014

How to Get Login Alerts via Email when Root user logs in through SSH in centos

A very good practice is to know when any body logs in to your server using root user, To configure your server to send a email alert when someone logs in as root in your server follow the steps below.
  • SSH server as root user
  • yum install mailx
  • cd /root
  • vi .bashrc
Copy the line below and paste it at the end.
  • echo 'ALERT - Root Shell Access on (server.hostname.com) on:' `date` from `who` | mail -s "Alert: Root Access from `who | cut -d'(' -f2 | cut -d')' -f1`" contact@dexterserver.com
  • Save and exit
Now whenever any body will login as root user in the server you will get the email alert with the IP from which login was made.

No comments:

Post a Comment

Do Write about the Blog and Welcome to the world where open source is every thing :-)