Created
September 23, 2024 17:10
-
-
Save stilliard/de338ee5e3f1893460c53acf2eeeff98 to your computer and use it in GitHub Desktop.
Email on ssh login
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
# Save file to /etc/profile.d/ssh-alerts.sh | |
# email on ssh login | |
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