大网数据广告活动
服务器运维问答

Harassed by ssh connection attempts, how to make fail2ban more strict?

· 52CE 我爱测

I use the default fail2ban configuration for ssh connection attempts on my Debian server hosting my web and mail servers. I already switched away from the default ssh port and things were quite for a long time. It seam that my se…

问题原文

原帖链接 · chmike · CC BY-SA 4.0

I use the default fail2ban configuration for ssh connection attempts on my Debian server hosting my web and mail servers.

I already switched away from the default ssh port and things were quite for a long time. It seam that my server got caught in the radar of some hacker in control of a bot network. I’m suddenly harassed by hundreds connection attempts for some days now on this secondary port.

Most of these connection attempts try invalid user names. There is no chance they get in with these, but I would prefer to keep them away.

I can’t install port knocking since I use ansible to automatically configure the server. I don’t know how to combine the two.

An intermediate solution would be to make fail2ban more penalizing with ssh connection attempts using a bad user name. Since I use ssh/config I never make a mistake with my user name and I can always connect with my phone if needed where the user name is also registered. That would be nice for dovecot as well.

Is it possible to configure fail2ban to jail an IP for a very long time if the connection failed because the user name was invalid ?

I’m running Debian 10 (Buster). Fail2ban is version 0.10.2. Ssh is version 7.9p1.

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

Just change the bantime to whatever time period you want, or -1 to ban forever.

bantime is expressed as a number of seconds, or -1. Recent versions (I think 0.9.x or later) accept suffixes for longer time periods, such as minute, hour, day, or week.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-03-12)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。