#!/bin/bash # Fail2ban installation script for Raspbian # # Copyleft 2017 by Ignacio Nunez Hernanz # GPL licensed (see end of file) * Use at your own risk! # # More at: https://ownyourbits.com/2017/02/24/nextcloudpi-fail2ban-installer/ # ACTIVE_=no # time to ban an IP that exceeded attempts BANTIME_=600 # cooldown time for incorrect passwords FINDTIME_=600 # bad attempts before banning an IP MAXRETRY_=6 # email to send notifications to EMAIL_=optional@email.com MAILALERTS_=no DESCRIPTION="Brute force protection for SSH and NextCloud" install() { apt-get update apt-get install --no-install-recommends -y fail2ban whois update-rc.d fail2ban disable rm -f /etc/fail2ban/jail.d/defaults-debian.conf [[ "$DOCKERBUILD" == 1 ]] && { cat > /etc/services-available.d/100fail2ban < /etc/fail2ban/filter.d/nextcloud.conf <<'EOF' [INCLUDES] before = common.conf [Definition] failregex = Login failed.*Remote IP.*'' ignoreregex = EOF [[ "$MAILALERTS_" == "yes" ]] && local ACTION=action_mwl || local ACTION=action_ cat > /etc/fail2ban/jail.conf <