Created
December 12, 2019 03:57
-
-
Save sprowell/c3cf9d04f52f764caa8b38d52071fea4 to your computer and use it in GitHub Desktop.
Script to notify alert@localhost on an SSH login or log out
This file contains 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
#!/bin/bash | |
PATH=/bin:/usr/bin:/usr/sbin | |
SUBJ="Alert - Remote SSH access from ${PAM_USER}" | |
if [ -z "$PAM_TYPE" -o "$PAM_TYPE" == "open_session" ] | |
then | |
sendmail alert <<END | |
$(hostname) $(date): LOGIN by ${PAM_USER} from ${PAM_RHOST} | |
$(who) | |
END | |
else | |
sendmail alert <<END | |
$(hostname) $(date): LOG OUT by ${PAM_USER} from ${PAM_RHOST} | |
END | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment