Просмотр исходного кода

Remove duplicate ssh fail2ban jail

Fixes #585
Robert Zollner 6 лет назад
Родитель
Сommit
ef655e256b
3 измененных файлов с 16 добавлено и 0 удалено
  1. 3 0
      install/hst-install-debian.sh
  2. 4 0
      install/hst-install-ubuntu.sh
  3. 9 0
      install/upgrade/versions/latest.sh

+ 3 - 0
install/hst-install-debian.sh

@@ -1614,6 +1614,9 @@ if [ "$fail2ban" = 'yes' ]; then
         chmod 640 /var/log/auth.log
         chmod 640 /var/log/auth.log
         chown root:adm /var/log/auth.log
         chown root:adm /var/log/auth.log
     fi
     fi
+    if [ -f /etc/fail2ban/jail.d/defaults-debian.conf ]; then
+        rm -f /etc/fail2ban/jail.d/defaults-debian.conf
+    fi
     update-rc.d fail2ban defaults
     update-rc.d fail2ban defaults
     systemctl start fail2ban
     systemctl start fail2ban
     check_result $? "fail2ban start failed"
     check_result $? "fail2ban start failed"

+ 4 - 0
install/hst-install-ubuntu.sh

@@ -1535,6 +1535,10 @@ if [ "$fail2ban" = 'yes' ]; then
         fline=$(echo "$fline" |grep enabled |tail -n1 |cut -f 1 -d -)
         fline=$(echo "$fline" |grep enabled |tail -n1 |cut -f 1 -d -)
         sed -i "${fline}s/false/true/" /etc/fail2ban/jail.local
         sed -i "${fline}s/false/true/" /etc/fail2ban/jail.local
     fi
     fi
+    if [ -f /etc/fail2ban/jail.d/defaults-debian.conf ]; then
+        rm -f /etc/fail2ban/jail.d/defaults-debian.conf
+    fi
+
     update-rc.d fail2ban defaults
     update-rc.d fail2ban defaults
     systemctl start fail2ban >> $LOG
     systemctl start fail2ban >> $LOG
     check_result $? "fail2ban start failed"
     check_result $? "fail2ban start failed"

+ 9 - 0
install/upgrade/versions/latest.sh

@@ -91,3 +91,12 @@ for user in $($HESTIA/bin/v-list-sys-users plain); do
         $HOMEDIR/$user/.composer \
         $HOMEDIR/$user/.composer \
         $HOMEDIR/$user/.ssh
         $HOMEDIR/$user/.ssh
 done
 done
+
+# Remove redundant fail2ban jail
+if fail2ban-client status sshd > /dev/null 2>&1 ; then
+    fail2ban-client stop sshd
+    if [ -f /etc/fail2ban/jail.d/defaults-debian.conf ]; then
+        mkdir -p $HESTIA_BACKUP/conf/fail2ban/jail.d
+        mv /etc/fail2ban/jail.d/defaults-debian.conf $HESTIA_BACKUP/conf/fail2ban/jail.d/
+    fi
+fi