fail2ban和ssh不起作用

我只用端口2122和pubkeyconfiguration了ssh。 我担保,但我想要更多的禁止拉姆斯尝试bruteforce auth。

我的fail2ban的configuration

jail.local [INCLUDES] before = paths-slackware.conf [DEFAULT] ignoreip = 127.0.0.1/8 ignorecommand = bantime = 10800 findtime = 600 maxretry = 3 backend = auto usedns = warn logencoding = auto enabled = true filter = %(__name__)s destemail = root@localhost sender = root@localhost mta = mail protocol = tcp chain = INPUT port = 0:65535 fail2ban_agent = Fail2Ban/%(fail2ban_version)s banaction = iptables-multiport banaction_allports = iptables-allports action_ = %(banaction)s[name=%(__name__)s, bantime="%(bantime)s", port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"] action_mw = %(banaction)s[name=%(__name__)s, bantime="%(bantime)s", port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"] %(mta)s-whois[name=%(__name__)s, sender="%(sender)s", dest="%(destemail)s", protocol="%(protocol)s", chain="%(chain)s"] action_mwl = %(banaction)s[name=%(__name__)s, bantime="%(bantime)s", port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"] %(mta)s-whois-lines[name=%(__name__)s, sender="%(sender)s", dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s"] action_xarf = %(banaction)s[name=%(__name__)s, bantime="%(bantime)s", port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"] xarf-login-attack[service=%(__name__)s, sender="%(sender)s", logpath=%(logpath)s, port="%(port)s"] action_cf_mwl = cloudflare[cfuser="%(cfemail)s", cftoken="%(cfapikey)s"] %(mta)s-whois-lines[name=%(__name__)s, sender="%(sender)s", dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s"] action_blocklist_de = blocklist_de[email="%(sender)s", service=%(filter)s, apikey="%(blocklist_de_apikey)s", agent="%(fail2ban_agent)s"] action_badips = badips.py[category="%(__name__)s", banaction="%(banaction)s", agent="%(fail2ban_agent)s"] action_badips_report = badips[category="%(__name__)s", agent="%(fail2ban_agent)s"] action = %(action_)s [ssh] enabled = true port = 22 filter = sshd logpath = /var/log/messages maxretry = 3 findtime = 10800 bantime = 21600 [apache] enabled = true port = http,https filter = apache-auth logpath = /var/chroothttp/var/log/httpd/error_log maxretry = 3 findtime = 10800 bantime = 21600 

阿帕奇正在工作完美,我已经尝试了一些不良login,并禁止IP的但是SSH试试,再试..没有禁止!

如果SSH不在端口22上运行,login到/var/log/messageslogin尝试将不会失败,因此Fail2Ban没有关于禁止哪些IP地址的信息。

但是,由于您没有在22号端口上运行任何服务,您实际上并不需要禁止。

如果您在非标准端口上运行ssh,则需要更新fail2banconfiguration以关注该端口,而不仅仅是指定的服务(因为它假定指定的服务正在其标准端口上运行)。

引用另一个答案 :

fail2ban将检测login尝试与日志内容。 fail2ban不要使用端口进行检测,只能阻塞。 要阻止正确的端口,你必须告诉fail2ban哪一个才能正确设置iptable。 进入/etc/fail2ban/jail.local

[ssh]
enabled = true
port = ssh <-- just modify this with your port port = 1234

然后重新启动fail2ban。

ATM的解决scheme是:fail2ban不禁止,如果pubkey唯一身份validation启用。 如果有人find另一个解决scheme…答复