Do you wish to be notified by email whenever someone login to the server as root? The tip that you read below is useful if more than one admins know the server root password, and you want to know when and where they access the server from.
To make this possible, just edit the file
/root/.bashrc and add the below line at the end of the file:
echo 'ALERT - Root Shell Access (YourserverName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" firstname.lastname@example.org
YourServerName‘ with the handle for your actual server and ‘
email@example.com‘ with your actual email address.
How does this work? You may ask!
/home/<user>/.bashrc is one of the scripts executed when a successful login for that user occur. Since we have to be alerted during root logins, we place this code at the end of
Consider the case that you wish to be alerted when a user, say ‘
joe‘ login to his account. In that case you can paste the one line code to