Kopano Fail2ban Filter

Kopano Fail2ban Filter

()

Kopano Server Attacken Schutz mit Fail2ban Filter

Dieses Howto beschreibt die Installation und Konfiguration von Fail2ban für die Kopano Groupware auf Ubuntu. Fail2ban bietet effektiven schutz gegen Brute-Force Attacken, in dem aus Syslog und Apache Protokoll fehlgeschlagene Versuche von Authentifizierungen herausgefiltert werden, um anschliessend den Host für eine bestimmte Zeit mittels Kernel Firewall zu blockieren.

Installation Fail2ban auf Kopano Server

Das Paket Fail2ban wird auf Ubuntu als root wie folgt installiert. Fail2ban ist auf Python entwickelt, weshalb die erforderlichen Bibliotheken nachgeladen werden.

$ apt-get update
$ apt-get install fail2ban -y

Nach der Installation wird Fail2ban ausgeführt und in systemd für den autostart aktiviert.

$ systemctl start fail2ban
$ systemctl enable fail2ban

Fail2ban Filter für Kopano bereitstellen

Ein Filter für Kopano bereitstellen, wir erstellen die Datei kopano-webapp-auth.conf

$ vi /etc/fail2ban/filter.d/kopano-webapp-auth.conf

Den Inhalt mit folgenden Zeilen in die Filter Datei einfügen:

# Fail2Ban kopano-webbapp-auth filter
# /etc/fail2ban/filter.d/kopano-webapp-auth.conf

[INCLUDES]
before = apache-common.conf

[Definition]
failregex = ^%(_apache_error_client)s Kopano WebApp user:.* authentication failure at MAPI

ignoreregex =

Fail2ban Filter in jail.conf aktivieren

Aktiviere den Fail2ban Filter für Kopano, mit erstellen der Konfigurationsdatei jail.local.

$ vi /etc/fail2ban/jail.local

Und den folgenden Inhalt einfügen:

[sshd]
port    = ssh
logpath = %(sshd_log)s

[kopano-webapp]
enabled = true
port    = https
filter  = kopano-webapp-auth
logpath = %(apache_error_log)s

[apache-auth]
enabled = true
port    = http,https
logpath = %(apache_error_log)s

Hier wird error.log ausgelesen mit der Variable %(apache_error_log), /var/log/apache2/error.log

Fail2ban erneut starten um die änderungen zu aktivieren.

$ systemctl restart fail2ban

Fail2ban Client Status überprüfen

Den Status von Fail2ban kann wie folgt überprüft werden.

$ fail2ban-client status
Status
|- Number of jail:      3
`- Jail list:   apache-auth, kopano-webapp, sshd
 
root@kopano:~# fail2ban-client status kopano-webapp
Status for the jail: kopano-webapp
|- Filter
|  |- Currently failed: 0
|  |- Total failed:     7
|  `- File list:        /var/log/apache2/mattermost-error.log /var/log/apache2/error.log
`- Actions
   |- Currently banned: 4
   |- Total banned:     52
   `- Banned IP list: 10.10.10.101 172.17.88.91 172.31.16.3 10.32.57.98

Die Firewall gibt Aufschluss über den Status der aktuell durch Fail2ban geblockten Quellen, mit einer iptables Abfrage:

$ iptables -vnL | egrep "f2b-kopano-webapp|apache-auth|sshd"
Kopano Fail2ban Filter

Fail2ban intrusion prevention software framework

Fail2ban is an intrusion prevention software framework. Written in the Python programming language, it is designed to prevent brute-force attacks. It is able to run on POSIX systems that have an interface to a packet-control system or firewall installed locally, such as iptables or TCP Wrapper.

Fail2ban operates by monitoring log files (e.g. /var/log/auth.log, /var/log/apache/access.log, etc.) for selected entries and running scripts based on them. Most commonly this is used to block selected IP addresses that may belong to hosts that are trying to breach the system’s security. It can ban any host IP address that makes too many login attempts or performs any other unwanted action within a time frame defined by the administrator.

It includes support for both IPv4 and IPv6. Optionally longer bans can be custom-configured for „recidivist“ abusers that keep coming back. Fail2ban is typically set up to unban a blocked host within a certain period, so as to not „lock out“ any genuine connections that may have been temporarily misconfigured. However, an unban time of several minutes is usually enough to stop a network connection being flooded by malicious connections, as well as reducing the likelihood of a successful dictionary attack.

Wie hilfreich war dieser Beitrag?

Klicke auf die Sterne um zu bewerten!

Durchschnittliche Bewertung / 5. Anzahl Bewertungen:

Bisher keine Bewertungen! Sei der Erste, der diesen Beitrag bewertet.

Es tut uns leid, dass der Beitrag für dich nicht hilfreich war!

Lasse uns diesen Beitrag verbessern!

Wie können wir diesen Beitrag verbessern?

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert