You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
593 B
17 lines
593 B
#!/bin/bash |
|
|
|
GOTIFY_FILE=$(<~/.gotify) |
|
GOTIFY_TOKEN=${GOTIFY_FILE##*( )} |
|
HOST="$(hostname)" |
|
sender="SSH-Notification <mail>" |
|
recipient="<mail>" |
|
subject="SSH Login: $PAM_USER from $PAM_RHOST on $HOST" |
|
message="User $PAM_USER logged in on $HOST from $PAM_RHOST at $(date)." |
|
|
|
if [ "$PAM_TYPE" == "open_session" ]; then |
|
if [ -n "$GOTIFY_TOKEN" ]; then |
|
curl -F "title=$subject" -F "message=$message" -F "priority=5" "https://push.sp-codes.de/message?token=$GOTIFY_TOKEN" |
|
elif [ "$PAM_USER" != "root" ]; then |
|
echo "$message" | mailx -a "From: $sender" -s "$subject" "$recipient" |
|
fi |
|
fi
|
|
|