Skip to content

Instantly share code, notes, and snippets.

@jsonUK
Created November 8, 2019 11:58
Show Gist options
  • Save jsonUK/ad1ade3ca585c1f6ca3a214faa385137 to your computer and use it in GitHub Desktop.
Save jsonUK/ad1ade3ca585c1f6ca3a214faa385137 to your computer and use it in GitHub Desktop.
Email alert every time someone logs into a VPS box/server via SSH
# Place this at the bottom of your /etc/profile file
if [ -n "$SSH_CLIENT" ]; then
TEXT="$(date): ssh login to ${USER}@$(hostname -f)"
TEXT="$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')"
echo $TEXT|mail -s "ssh login" myemail@example.com
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment