mirror of
https://github.com/guezoloic/serverconfig.git
synced 2026-01-25 15:34:23 +00:00
add notification and update aws-backup (the changes will come soon)
This commit is contained in:
19
notification/sshd-login.sh
Normal file
19
notification/sshd-login.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!bin/bash
|
||||
|
||||
source /etc/serverconfig/.env
|
||||
|
||||
case "$PAM_TYPE" in
|
||||
open_session)
|
||||
PAYLOAD=" { \"text\": \"$PAM_USER logged in (remote host: $PAM_RHOST) at $(date).\" }"
|
||||
;;
|
||||
close_session)
|
||||
PAYLOAD=" { \"text\": \"$PAM_USER logged out (remote host: $PAM_RHOST) at $(date).\" }"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$PAYLOAD" ] ; then
|
||||
curl -X POST "https://api.telegram.org/bot$TOKEN/sendMessage" \
|
||||
-d "chat_id=$CHAT_ID" \
|
||||
-d "text=$PLAYLOAD" \
|
||||
-d "parse_mode=HTML"
|
||||
fi
|
||||
Reference in New Issue
Block a user