Fixes
This commit is contained in:
parent
69394a563b
commit
0720ffafb9
|
@ -1,18 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
cat << 'EOF' > /etc/ssh/login-alert.sh
|
||||
#!/bin/bash
|
||||
|
||||
source /etc/mailinabox.conf # load global vars
|
||||
|
||||
cat <<EOF >> /etc/ssh/login-alert.sh
|
||||
#!/bin/sh
|
||||
sender="bot@PRIMARY_HOSTNAME"
|
||||
recepient="admin@$PRIMARY_HOSTNAME"
|
||||
|
||||
if [ "$PAM_TYPE" != "close_session" ]; then
|
||||
subject="SSH Login: $PAM_USER from $PAM_RHOST"
|
||||
# Message to send, e.g. the current environment variables.
|
||||
message="If you don't recognize this login, your key or password may be compromised."
|
||||
echo "$message" | mailx -r "$sender" -s "$subject" "$recepient"
|
||||
IP=$(echo $SSH_CONNECTION | cut -d ' ' -f 1)
|
||||
sendEmail -q -f "bot@$PRIMARY_HOSTNAME" -t "admin@$PRIMARY_HOSTNAME" -u "SSH Login: $PAM_USER from $PAM_RHOST" -m "If you don't recognize this login, your key or password may be compromised."
|
||||
fi
|
||||
EOF
|
||||
|
||||
chmod +x /etc/ssh/login-alert.sh
|
||||
|
||||
echo 'session optional pam_exec.so seteuid /etc/ssh/login-alert.sh' >> /etc/pam.d/sshd
|
||||
if grep -Fq "login-alert" /etc/pam.d/sshd
|
||||
then
|
||||
:
|
||||
else
|
||||
echo 'session optional pam_exec.so seteuid /etc/ssh/login-alert.sh' >> /etc/pam.d/sshd
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue