mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-04-21 03:02:09 +00:00
Merge e7491dffd6
into 4c36d6e6c9
This commit is contained in:
commit
6764050241
22
setup/login-alerts.sh
Normal file
22
setup/login-alerts.sh
Normal file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Create a script to be called when a user logs in
|
||||
cat << 'EOF' > /etc/ssh/login-alert.sh
|
||||
#!/bin/bash
|
||||
|
||||
source /etc/mailinabox.conf # load global vars
|
||||
|
||||
if [ "$PAM_TYPE" != "close_session" ]; then
|
||||
# send alert
|
||||
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 # make script executable
|
||||
|
||||
if grep -Fq "login-alert" /etc/pam.d/sshd # if line has already been added to sshd
|
||||
then
|
||||
: # do nothing
|
||||
else
|
||||
echo 'session optional pam_exec.so seteuid /etc/ssh/login-alert.sh' >> /etc/pam.d/sshd # otherwise add the line
|
||||
fi
|
@ -102,6 +102,7 @@ source setup/dns.sh
|
||||
source setup/mail-postfix.sh
|
||||
source setup/mail-dovecot.sh
|
||||
source setup/mail-users.sh
|
||||
source setup/login-alerts.sh
|
||||
source setup/dkim.sh
|
||||
source setup/spamassassin.sh
|
||||
source setup/web.sh
|
||||
|
Loading…
Reference in New Issue
Block a user