Created
September 18, 2018 22:44
-
-
Save souhaiebtar/8cec2a2166ffa083d31c01f65ce86d02 to your computer and use it in GitHub Desktop.
ssh login email alert #ssh #login #mail
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 | |
if [ "$PAM_TYPE" != "close_session" ]; then | |
APK='api:00301be59a4ff645f2db693ba971a23b-8b7bf2f1-568a4476' | |
FROM='Login Alert <postmaster@email.tsouhaieb.space>' | |
TO='tarhounisouhaieb@gmail.com' | |
SUBJECT="Login: $PAM_USER @ email.tsouhaieb.space from $PAM_RHOST" | |
DATE=$(date) | |
TEXT="At $DATE a login occurred for $PAM_USER on the VPS from $PAM_RHOST" | |
curl -s --user $APK \ | |
https://api.mailgun.net/v3/email.tsouhaieb.space/messages \ | |
-F from="$FROM" \ | |
-F to="$TO" \ | |
-F subject="$SUBJECT" \ | |
-F text="$TEXT" | |
fi | |
#echo "session optional pam_exec.so seteuid /root/login-alert.sh" >> /etc/pam.d/sshd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment