Skip to content

Instantly share code, notes, and snippets.

@chuenniger
Last active June 21, 2018 20:03
Show Gist options
  • Save chuenniger/b93911ffe200ba1b93f02c22e23f2c28 to your computer and use it in GitHub Desktop.
Save chuenniger/b93911ffe200ba1b93f02c22e23f2c28 to your computer and use it in GitHub Desktop.
Email Notification on SSH login
# 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