New Blog Post: Email notification when someone logs in via SSH

Email notification when someone logs in via SSH
Author: @mikho

Excerpt:

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

editor .bashrc

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

echo 'ALERT - Root Shell Access (ServerName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" [email protected]

...

Read the full post here:
https://lowendspirit.com/email-notification-when-someone-logs-in-via-ssh/

Sign In or Register to comment.