Site is Under Maintenance
Please come back again in...
00 Days
00 Hours
00 Minutes
00 Seconds

How to Configure Email Alerts on Linux Root Login

To increase the security of your Linux server, you can configure Bash so it sends an e-mail whenever someone logs in using the root account. This is how you do it:

[root@VPS1 ~]# vim /root/.bashrc
At the bottom add the following line:

echo 'ALERT - Root Shell Access (SERVERNAME) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" EMAIL
Just replace SERVERNAME with the name of your server and EMAIL with your e-mail address. The next time you log in with the root account, you will receive an e-mail like this one:

ALERT – Root Shell Access (SERVERNAME) on: Mon Apr 22 20:16:24 CEST 2013 admin pts/0 2013-04-22 20:16 (1234.cm-5-1a.dynamic.ziggo.nl)

The e-mail will show you the server name and the hostname of the user who logged in using the root account. That’s all there is to it! If you have any questions feel free to ask.

Happy Email Configuring!



Rate This Article

Thanks for reading: How to Configure Email Alerts on Linux Root Login, Sorry, my English is bad:)

Getting Info...

About the Author

I'm Aevon...Just a gal with an insane passion for all things cybersecurity. 17 years in the industry and still love what I'm doing.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.