Your Webhosting Questions
Answered by the Webhosting Experts

How to setup an Email alert when somebody has logged into your server as root?

For receiving an alert if someone logs in as root to your server, you will have to make

Some changes to .bashrc that is available under the ‘/root’ partition.

This file is a hidden, therefore you must use the -a flag with ls command to view all the

hidden files.

Specify the below code to the bottom of the existing code;-

echo ‘SSH Root Access (Your Server Name) on:’ `date` `who` | mail -s “ALERT: Root Access from `who | cut -d”(” -f2 | cut -d”)” -f1`” [email protected]

Then save and exit.

Its recommended not to enable root logins on SSH.

Also, it is useful to use an email address which isn’t hosted on the same server from

which the notifications would be sent.

Need More Personalized Help?

If you have any further issues, questions, or would like some assistance checking on this or anything else, please reach out to us from your account and provide your server credentials within the encrypted field for the best possible security and support.

If you are unable to reach your account or if you are on the go, please reach out from your valid account email to us here at: [email protected]. We are also available to you through our phone and live chat system 24/7/365.

Tags +