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 csf firewall is enabled on the server.

Step 2. Check 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 following parameter is enabled in csf -
LF_CPANEL_ALERT = "1"

You can then go ahead an add 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?

 Print this Article

Also Read

How to get backup data recursively from the Amazon server?

There may be a situation where you do not have a zip utility on Amazon server so, the backup...

How to Install or Uninstall EasyApache 4 on cPanel server?

EasyApache Software is included within your cPanel and WHM license which is very easy and useful...

How to setup SMTP port on Linux server using WHM?

By default SMTP outgoing server is configured for port 25. If you would like to allow exim to...

#1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation

While running one query from cPanel >> PhpMyAdmin, I was getting this error message -#1227...

Failed to connect to MySQL: Access denied for user

While accessing the website, I was getting the error as -Failed to connect to MySQL: Access...

Powered by WHMCompleteSolution