11 lines
411 B
Bash
11 lines
411 B
Bash
#!/bin/bash
|
|
|
|
sender="SSH-Notification <notifications@sp-codes.de>"
|
|
recipient="codes@samuel-philipp.de"
|
|
|
|
if [ "$PAM_TYPE" == "open_session" ] && [ "$PAM_USER" != "root" ]; then
|
|
HOST="`hostname`"
|
|
subject="SSH Login: $PAM_USER from $PAM_RHOST on $HOST"
|
|
message="User $PAM_USER logged in on $HOST from $PAM_RHOST at $(date)."
|
|
echo "$message" | mailx -a "From: $sender" -s "$subject" "$recipient"
|
|
fi
|