25 lines
453 B
Bash
25 lines
453 B
Bash
#!/bin/bash
|
|
# Ignore non interactive git shells like git since that's just annoying.
|
|
if [ -z "$SSH_TTY" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
# Your ntfy topic URL
|
|
NTFY_TOPIC="bla bla bla"
|
|
|
|
HOSTNAME=$(hostname)
|
|
USER="$PAM_USER"
|
|
IP="$PAM_RHOST"
|
|
TIME=$(date +"%Y-%m-%d %H:%M:%S %Z")
|
|
|
|
MESSAGE="SSH login
|
|
User: $USER
|
|
IP: $IP
|
|
Host: $HOSTNAME
|
|
Time: $TIME"
|
|
|
|
curl -s -X POST "$NTFY_TOPIC" \
|
|
-H "Title: New SSH Login detected !" \
|
|
-H "Priority: 4" \
|
|
-d "$MESSAGE"
|