Created
November 8, 2019 11:58
-
-
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
This file contains hidden or 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
# 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" [email protected] | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment