Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Alternatives to Fail2ban?
6 points by jech 14 days ago | hide | past | favorite | 10 comments
I'm administering a small number of Linux servers that run an ssh server exposed to the Internet. I usually connect using a cryptographic key, but I still allow password authentication in case of trouble (perhaps I'm being overly cautious). I've been using fail2ban with good results, but I'm annoyed at having to install a Python interpreter on every server.

Is there an alternative to fail2ban that is just a single binary? It doesn't need to have all of the features of fail2ban, blocking dictionary attacks against ssh is all I need.



sshguard is exactly this - single C binary, no interpreter needed. It tails your logs (journalctl/syslog) and bans offenders via iptables/nftables/pf. No Python, no dependencies beyond the firewall backend: https://www.sshguard.net/

How did I miss this? I have a stack begging to try this out, and for the same reasons as OP. Thank you.

One hour later, it appears that sshguard is working fine. It's structured as a dozen binaries or so, but it has no dependencies. I haven't done any CPU usage measurements, but I haven't seen it appear in top's output.

> sshguard is exactly this

Thanks. I've replaced fail2ban with sshguard on one machine, we'll see how it goes.


> an ssh server exposed to the Internet. I... still allow password authentication in case of trouble

You gotta get over that eventually and really, the sooner the better.


This isn't for everyone and it will block old ssh libraries (libssh, go ssh, etc...), windows and others but if you only have OpenSSH 10+ and that's all you connect with then this method [1] has worked well for me. It gets botters to exclude my nodes that expose SSH on purpose (such as public anonymous SFTP). If trying it out test from an out of band console first.

Edit: I should add, there will still be some syslog entries, but that can be filtered out using regex filters in rsyslog one so desired. Only do so once it is confirmed most of the brute forcing has stopped.

[1] - https://nochan.net/b/Internet-Crap/20260108-Confuse-Some-SSH...


Do you really need SSH exposed?

If not, use something like WireGuard (or Tailscale) and bind only to that interface.

You can also change the default port, your logs will quiet down dramatically.

Lastly, if you have a long enough passphrase with enough entropy/randomness, password authentication being enabled is probably fine, you can also set only a specific user allowed to SSH for additional hardening.


Disable password authentication and ignore the noise.

there is fail2zig seems to be exactly what you looking for

https://fail2zig.com


> https://fail2zig.com

Thanks. I've had a quick look, and it looks like it's a drop-in replacement for fail2ban (it claims to parse fail2ban's configuration files unchanged), except that it doesn't require a Python runtime.

I haven't tried it, since I'm currently happy with sshguard. I'm keeping the link handy in case I find I need more features than what sshguard provides.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: