Skip to content

Instantly share code, notes, and snippets.

@stilliard
Created September 23, 2024 17:10
Show Gist options
  • Save stilliard/de338ee5e3f1893460c53acf2eeeff98 to your computer and use it in GitHub Desktop.
Save stilliard/de338ee5e3f1893460c53acf2eeeff98 to your computer and use it in GitHub Desktop.
Email on ssh login
# 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