Skip to content

Instantly share code, notes, and snippets.

@mikaelz
Created November 23, 2019 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikaelz/be7607ffc9509ced8940bf5ab1e46334 to your computer and use it in GitHub Desktop.
Save mikaelz/be7607ffc9509ced8940bf5ab1e46334 to your computer and use it in GitHub Desktop.
SSH login email notify. Inspired by https://askubuntu.com/a/702743/168459
$ cat /etc/profile.d/ssh-login-notify.sh
if [ -n "$SSH_CLIENT" ]; then
TEXT="$(date): ssh login to ${USER}@$(hostnamectl --static)"
TEXT="$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')"
echo $TEXT|mail -s "ssh login" info@example.com
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment