Email notification when someone logs in via SSH

Even if it is too late when someone else logs in as root on your server, it is good to know that NOW is the time to get working on your security.

To setup email notification, login to your server as root.
Edit .bashrc

add the following line at the end, changing “ServerName” to the hostname of your server and “” to your own email address.

Save and exit.

Next time someone (hopefuly you) logs on as root, you will get an email about this.

This can be done for any user, you only have to make sure that the user can email out from your server.

11 comments for “Email notification when someone logs in via SSH

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.