Mehr Sicherheit durch fail2ban: Unterschied zwischen den Versionen
K Textersetzung - „</source>“ durch „</syntaxhighlight>“ |
Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
Das kleine Programm fail2ban lässt sich so konfigurieren, dass es einen Angreifer erkennt, wenn dieser versucht sich einzuloggen und er das Kennwort nicht weiß oder einen falschen SSH Key verwendet. Standardmäßig schließt dann fail2ban, mittels Firewall Regel (iptables), den Zugang für das angreifende System für x Minuten. Das ist eine der besten Waffen gegen BruteForce Angriffe. | |||
==Installation== | ==Installation== | ||
Debian/Ubuntu Linux | Debian/Ubuntu Linux | ||
<pre> | <pre> | ||
apt install fail2ban | |||
</pre> | </pre> | ||
==Konfiguration== | ==Konfiguration== | ||
=== Actions === | |||
<pre> | möchte man eine E-Mail erhalten, wenn es zu einer fail2ban Aktion kommt, kann man dies einfach durch das anlegen dieser Konfiguration machen. Die anderen Parameter setzten die Blockierungszeit und die Versuche bis eine Blockierung ausgelöst wird: | ||
<code>/etc/fail2ban/jail.d/action.conf</code><pre> | |||
[DEFAULT] | [DEFAULT] | ||
# Destination email address used solely for the interpolations in | # Destination email address used solely for the interpolations in | ||
# jail.{conf,local} configuration files. | # jail.{conf,local,d/*} configuration files. | ||
destemail = | destemail = YOURMAILADDRESS | ||
# Choose default action. To change, just override value of 'action' with the | # Choose default action. To change, just override value of 'action' with the | ||
# interpolation to the chosen action shortcut (e.g. action_mw, action_mwl, etc) in jail.local | # interpolation to the chosen action shortcut (e.g. action_mw, action_mwl, etc) in jail.local | ||
# globally (section [DEFAULT]) or per specific section | # globally (section [DEFAULT]) or per specific section | ||
action = %(action_mwl)s | |||
# "bantime" is the number of seconds that a host is banned. | |||
bantime = 30m | |||
# "maxretry" is the number of failures before a host get banned. | |||
maxretry = 3 | |||
</pre> | |||
=== Backend === | |||
solltet ihr ein neueres Debian Linux / Raspberry Pi OS (Bookworm und neuer) nutzen, muss das Backend von auto, auf systemd geändert werden: | |||
<code>/etc/fail2ban/jail.d/backend.conf</code><pre> | |||
[DEFAULT] | |||
# "backend" specifies the backend used to get files modification. | |||
# Available options are "pyinotify", "gamin", "polling", "systemd" and "auto". | |||
# This option can be overridden in each jail as well. | |||
# | # | ||
# in | # pyinotify: requires pyinotify (a file alteration monitor) to be installed. | ||
# If pyinotify is not installed, Fail2ban will use auto. | |||
# gamin: requires Gamin (a file alteration monitor) to be installed. | |||
# If Gamin is not installed, Fail2ban will use auto. | |||
# polling: uses a polling algorithm which does not require external libraries. | |||
# systemd: uses systemd python library to access the systemd journal. | |||
# Specifying "logpath" is not valid for this backend. | |||
# See "journalmatch" in the jails associated filter config | |||
# auto: will try to use the following backends, in order: | |||
# pyinotify, gamin, polling. | |||
# | # | ||
# | # Note: if systemd backend is chosen as the default but you enable a jail | ||
# | # for which logs are present only in its own log files, specify some other | ||
# backend for that jail (e.g. polling) and provide empty value for | |||
# journalmatch. See https://github.com/fail2ban/fail2ban/issues/959#issuecomment-74901200 | |||
backend = systemd | |||
</pre> | </pre> | ||
===Konfiguration für SSH=== | ===Konfiguration für SSH=== | ||
Folgendes der Datei hinzufügen:<br> | Folgendes der Datei hinzufügen:<br>''/etc/fail2ban/jail.local'' | ||
''/etc/fail2ban/jail.local'' | |||
<pre> | <pre> | ||
[ssh] | [ssh] | ||