How to enable root login alerts on cPanel server

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:

Step 3. Add your email address on which you would like to receive an email [email protected]:
LF_ALERT_TO = "[email protected]"

Step 4. Restart firewall.
csf -r

Alternatively, make sure the following parameter is enabled in CSF:

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`" [email protected]

Replace [email protected] with your email address.

That's it!

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to fix defaultwebpage.cgi on a webserver

Running the following commands solves the above problem:   /scripts/updateuserdomains...

How to fix IP Missing issue on cPanel/WHM

We are here to help you with solving the problem of Missing IP Server in list accounts. The...

Install Let's Encrypt SSL in cPanel/WHM

Let's Encrypt, a valid, open-source license that offers free SSL for your domains. The Let's...

Fix Email Issue on a server using the MSFE

To solve the problem of not sending/receiving email on a server using the MSFE / Mailscanner...

Domain names are not showing in WHM

We were unable to see any domains listed under WHM -> List Accounts. However, we can see the...