Portscans, Login Versuche und mod proxy requests blocken?
Hallo,
seid ein paar Tagen habe ich massive Portscans und Versuche (teilweise 10000 pro Tag von der gleichen IP) sich auf dem Server per SSH einzuloggen.
Geht zwar nicht, da keine Root Anmeldung möglich, SSH Port gewechselt, nur mit SSH Key + Passwort + 2 FA.
Trotzdem geht es mir auf die "Nerven".
Gibt es keine Möglichkeit das ganze mit Fail2Ban etc zu blocken?
Ich habe bereits eine Fail2Ban Regel, die läuft dabei aber ins Leere:
enabled = true
port = mein SSH Port
filter = sshd
maxretry = 1
logpath = %(sshd_log)s
backend = %(sshd_backend)s
#findtime: 1 year
findtime = 31536000
#bantime: 1 year
bantime = 31536000
Immer wieder mal sind auch mod_proxy requests dabei (Nginx). Auch hier habe ich eine Regel, die aber nur selten Wirkung zeigt.
[nginx-noproxy]
enabled = true
port = http,https
filter = nginx-noproxy
logpath = /var/log/nginx/access.log
maxretry = 0
#findtime: 1 year
findtime = 31536000
#bantime: 1 year
bantime = 31536000
Hat jemand Tipps?
Danke
seid ein paar Tagen habe ich massive Portscans und Versuche (teilweise 10000 pro Tag von der gleichen IP) sich auf dem Server per SSH einzuloggen.
Geht zwar nicht, da keine Root Anmeldung möglich, SSH Port gewechselt, nur mit SSH Key + Passwort + 2 FA.
Trotzdem geht es mir auf die "Nerven".
Gibt es keine Möglichkeit das ganze mit Fail2Ban etc zu blocken?
Ich habe bereits eine Fail2Ban Regel, die läuft dabei aber ins Leere:
enabled = true
port = mein SSH Port
filter = sshd
maxretry = 1
logpath = %(sshd_log)s
backend = %(sshd_backend)s
#findtime: 1 year
findtime = 31536000
#bantime: 1 year
bantime = 31536000
Immer wieder mal sind auch mod_proxy requests dabei (Nginx). Auch hier habe ich eine Regel, die aber nur selten Wirkung zeigt.
[nginx-noproxy]
enabled = true
port = http,https
filter = nginx-noproxy
logpath = /var/log/nginx/access.log
maxretry = 0
#findtime: 1 year
findtime = 31536000
#bantime: 1 year
bantime = 31536000
Hat jemand Tipps?
Danke
Please also mark the comments that contributed to the solution of the article
Content-Key: 1455898970
Url: https://administrator.de/contentid/1455898970
Printed on: April 26, 2024 at 06:04 o'clock
5 Comments
Latest comment
naja - schau dir die doku zu fail2ban an. Natürlich kannst du damit die ssh-logins machen, ich blocke z.B. nach 3 fehlgeschlagenen Versuchen die IP für 24h (ich würde empfehlen eine sinnvolle Zeit zu nehmen, ist ja blöd wenn du dich selbst permanent aussperrst weil du z.B. an nem Rechner bist wo du deinen Key nich hinterlegen kannst/willst).
Generell kannst du damit natürlich auch Logfiles überprüfen, für die meisten hat es ja sogar standard-files dabei...
Generell kannst du damit natürlich auch Logfiles überprüfen, für die meisten hat es ja sogar standard-files dabei...
Hallo,
also wenn ich mir die default sshd.conf vom meinem fail2ban ansehe dann seht da schon mehr drinne.
also wenn ich mir die default sshd.conf vom meinem fail2ban ansehe dann seht da schon mehr drinne.
# Fail2Ban configuration file
#
# Author: Cyril Jaquier
#
# $Revision$
#
[INCLUDES]
# Daemon definition is to be specialized (if needed) in .conf file
_daemon = \S*
#
# Shortcuts for easier comprehension of the failregex
#
# PID.
# EXAMPLES: [123]
__pid_re = (?:\[\d+\])
# Daemon name (with optional source_file:line or whatever)
# EXAMPLES: pam_rhosts_auth, [sshd], pop(pam_unix)
__daemon_re = [\[\(]?%(_daemon)s(?:\(\S+\))?[\]\)]?:?
# Combinations of daemon name and PID
# EXAMPLES: sshd[31607], pop(pam_unix)[4920]
__daemon_combs_re = (?:%(__pid_re)s?:\s+%(__daemon_re)s|%(__daemon_re)s%(__pid_re)s?:)
# Some messages have a kernel prefix with a timestamp
# EXAMPLES: kernel: [769570.846956]
__kernel_prefix = kernel: \[\d+\.\d+\]
__hostname = \S+
#
# Common line prefixes (beginnings) which could be used in filters
#
# [hostname] [vserver tag] daemon_id spaces
# this can be optional (for instance if we match named native log files)
__prefix_line = \s*(?:%(__hostname)s )?(?:%(__kernel_prefix)s )?(?:@vserver_\S+ )?%(__daemon_combs_re)s?\s*
__prefix_line = \s*(?:%(__hostname)s )?(?:%(__kernel_prefix)s )?(?:@vserver_\S+ )?%(__daemon_combs_re)s?\s*
[Definition]
_daemon = sshd
# Option: failregex
# Notes.: regex to match the password failures messages in the logfile. The
# host must be matched by a group named "host". The tag "<HOST>" can
# be used for standard IP/hostname matching and is only an alias for
# (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
# Values: TEXT
#
failregex = ^%(__prefix_line)s(?:error: PAM: )?Authentication failure for .* from <HOST>\s*$
^%(__prefix_line)s(?:error: PAM: )?User not known to the underlying authentication module for .* from <HOST>\s*$
^%(__prefix_line)sFailed (?:password|publickey) for .* from <HOST>(?: port \d*)?(?: ssh\d*)?$
^%(__prefix_line)sROOT LOGIN REFUSED.* FROM <HOST>\s*$
^%(__prefix_line)s[iI](?:llegal|nvalid) user .* from <HOST>\s*$
^%(__prefix_line)sUser .+ from <HOST> not allowed because not listed in AllowUsers$
^%(__prefix_line)sauthentication failure; logname=\S* uid=\S* euid=\S* tty=\S* ruser=\S* rhost=<HOST>(?:\s+user=.*)?\s*$
^%(__prefix_line)srefused connect from \S+ \(<HOST>\)\s*$
^%(__prefix_line)sAddress <HOST> .* POSSIBLE BREAK-IN ATTEMPT!*\s*$
^%(__prefix_line)sUser .+ from <HOST> not allowed because none of user's groups are listed in AllowGroups\s*$
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#
ignoreregex =