SSH Login Notification

Someone might say I’m paranoid but i like to now when someone logs into my server.

Copy this into the file “/etc/ssh/sshrc” (Ubuntu/Debian) and change “user@example.com” to your email address:

IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
HOST=$(hostname)
echo ''$IP' logged into '$HOST'' | mutt -s 'SSH Login' user@example.com

This example only works if you have configured the Mutt email client.