How to enable root login alerts on cPanel server Print

  • 0

For security reasons, you would like to get an alert to your mailbox if someone logins to the server with root credentials.

Step 1. Make sure the CSF firewall is enabled on the server.

Step 2. Check the CSF configuration file.

Make sure below values are set to 1:
LF_SSH_EMAIL_ALERT = "1"

Step 3. Add your email address on which you would like to receive an email your@yourdomain.com:
LF_ALERT_TO = "your@yourdomain.com"

Step 4. Restart firewall.
csf -r

Alternatively, make sure the following parameter is enabled in CSF:
LF_CPANEL_ALERT = "1"

You can then go ahead and add the following code to bashrc file:

cd /root
nano .bashrc
echo 'ALERT - Root Shell Access (ServerName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d'(' -f2 | cut -d')' -f1`" your@yourdomain.com

Replace your@yourdomain.com with your email address.

That's it!


Was this answer helpful?

« Back

Send Message