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

DenyIp::adddenyip(xxx.xxx.xxx.xxx) failed: Error: while opening /home/xxx/public_html/.htaccess Error: while opening /home/xxx/public_html/.htaccess

I was getting the below error while adding an IP address from cPanel >> IP Blocker...

How to to know SSH port on the cPanel server?

Steps to know SSH port of cPanel server -1. Login to WHM with your login details. 2. Go to...

How to reset Joomla Admin Panel Password?

Many times we used to forgot the current password of Joomla Administration panel and get in...

How to access phpMyAdmin without login to cPanel?

Many times you will get the question from client that -I want to provide access the phpMyAdmin to...

SMTP Error (550): Failed to add recipient

While sending email from webmail, I was getting the below error : SMTP Error (550): Failed to...

Powered by WHMCompleteSolution