Last active
June 21, 2018 20:03
-
-
Save chuenniger/b93911ffe200ba1b93f02c22e23f2c28 to your computer and use it in GitHub Desktop.
Email Notification on SSH login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from here: https://www.vultr.com/docs/enable-ssh-login-notification-on-linux | |
# vim /etc/ssh/sshrc | |
IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)" | |
HOSTNAME=$(hostname) | |
NOW=$(date +"%e %b %Y, %a %r") | |
echo 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' | mail -s 'SSH Login Notification' <YOUR_EMAIL_ADDRESS> | |
# service sshd restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment