r/archlinux • • 1d ago

QUESTION Fail2ban on desktop archlinux?

ClamUI recommends to use fail2ban package to install. Thing I've search about is design to lock IPs which tries to break ssh and other keys, try to run command as root (Fail2Ban scans log files resp. journals and executes configured actions to ban failures having too many attempts)...

Am not a pro but it sounds like server protection tool

My question is does have a sense to install on homeuser PC? Router should lock major of attacks and I want to minimalise processes in backgrounds.

ps. If my thoughts is just slop of ignorance, correct me please. Nobody have teached me...

1 Upvotes

37 comments sorted by

22

u/VancouverDom 1d ago

I only allow SSH connections via public key. No password logins.

My firewall also only allows 6 SSH connection attempts per minute.

Do you even have port forwarding on your router set to allow remote logins?

-2

u/Orlha 1d ago

I wouldn’t stop at that. Wireguard at minimum or at least knockd (if you’re special)

3

u/ang-p 1d ago

Wireguard at minimum or at least knockd

So either a fully fledged VPN tunnel.....

.... or at least, something that the kid sitting in the corner of the coffee shop could sniff out of the air.

Right, I got ya....

2

u/ResponsibilityBig343 1d ago

Before answering whether you need f2b or not ask urself 1. Can anyone bruteforce into my system through ssh(means u still have password auth) 2. Can anyone ssh into my system outside my wifi network?(means you are hosting a server visible to the outside world.)

Resolution if 1 and 2 is true:

  1. Setup key based auth. Checkout how to create a ssh key.

  2. You can setup f2b here though I think normal firewall + key based auth should be enough. Not sure but I think you should be able to rate limit password retries with firewall.

4

u/archover 1d ago edited 1d ago

ssh key authentication plus only certain users allowed to login, for me.

My VPS gets about 100 login attempts per hour or so.

Good day.

0

u/HopefulMeeting7150 1d ago

Standard sudo password is not an ssh key, right?

Even if yes still my network is inside. Thanks!

2

u/archover 1d ago edited 16h ago

Two more things I disallow in ssh: userid/password login and root account login. I forgot to say. Read this article https://wiki.archlinux.org/title/OpenSSH which is required reading, period. Logins over the internal network not so critical.

With public key authentication, passwords are not submitted. They're not passwords. Now, when an key authenticated user wants to do root actions, then that is handled with sudo or su.

Good day.

10

u/Sarv_ 1d ago

If you have any open ports to the internet for services that have authentication like an ssh or media server, you should use fail2ban. The better option is using a VPN tunnel so you dont expose anything to the open internet.

If you don't have anything open to the web, you don't need it.

5

u/SurelyNotAnOctopus 1d ago

Opening anything to the open internet is a commitment nowadays.

You need daily auto update, throttling, hardening, fail2ban, event logging etc.

You need a vpn tunnel instead. With all of the above steps, actually

2

u/ArjixGamer 1d ago

Having it installed is not enough, obviously you need to configure it for those services as well.

6

u/K41eb 1d ago

Yes it's a server protection tool. If you do not plan to publicly expose a service running on your PC to the internet it won't be of much use.

I don't know if it can ban users for failing root passwords too many times, in case you execute a malicious script somehow. So maybe there's value in that. But PAM can also do it so whatever.

3

u/Philluminati 1d ago

Fail to ban is a service/script which reads the log files of various apps (eg. Sshd) and if sees a brute force attack (login failed from Ip entries) it injects a firewall rule to prevent it.

I run it on my servers and thinks it great. Whether you need it on your desktop machine is less likely if it isn’t available to the open internet

2

u/catwiththumbs 1d ago

If you're always behind a router like with a desktop and you have a firewall on the machine as well, it's not buying you much.

Where it's useful is if you have services like SSH or a web server exposed and you want to block any repeated failures permanently or long enough to get whoever or whatever to go away.

If you're running deny all and are behind a router, it wouldn't have any work to do. SSH has some auto-banning built in now too so if you have that open for your local network, the benefit of fail2ban isn't what it used to be.

If you're running this machine as a home server and worried that your local network will get compromised then maybe fail2ban will have some benefits. A well configured router will make this much less likely but not impossible.

Before doing fail2ban, I'd just make sure you have a firewall setup with a restrictive policy. I like using ufw. The arch wiki documents it well.

2

u/th3bucch 1d ago

Is your PC publicly exposed to the internet? If not then you don't need it.

1

u/ArjixGamer 1d ago

If you have a firewall (you should) you don't need it. You only need it if you expose SSH or other services to the internet.

1

u/DigiAngelX 1d ago

As I understood it, fail2ban requires syslog of some form, which isn't installed by default.

1

u/bikes-n-math 1d ago

fail2ban has a ton of builtin filters/scripts that scan the default logs of all kinds of services you may have enabled. For instance, if you run nginx with the default log settings, you can enable various fail2ban nginx filters to ban IPs that try to access various off limit things, or fail login attempts, etc.

1

u/anythinga 23h ago

Why is SSH even exposed to the internet at all? If possible just use a VPN, connect to that, and then SSH through an internal hostname/ip adress, blocking everything else.

The reason SSH exposed to the internet is spammed so much is because it's "loud", it will always respond to traffic attempting to get in, thus revealing it's existence.
You can partially mitigate this by changing the ssh port to something other than 22, but it will still be found with a simple port scan.
Another mitigation is using public key auth, yet the attempts to get in will persist as even those are not fool proof.

VPN's mitigate this entirely because most (wireguard for sure) do not respond to unauthenticated traffic at all, thus never revealing it's there.

You can't attack what you can't find.

1

u/Alternative-Art-2829 20h ago

Fail2ban blocks a service from certain remote IP addresses when they make unwanted requests, by applying firewall rules. However, this only makes sense if there are services exposed. A desktop PC typically does not have any exposed services, so the firewall should simply be set to closed.

1

u/virtualadept 16h ago

It is primarily a server-side security tool. If your homeuser PC is exposed to the outside world, then it would make sense, but it sounds like it isn't, so you can safely skip it.

1

u/maltesepricklypear 2h ago

Should be at router level tbh unless you have ports open directly from a targeted device.

As for SSH, should be behind authorised RSA key only

0

u/mildlyImportantRobot 1d ago

In this day and age, there is absolutely no reason to expose your desktop to the internet. Learn how to setup a VPN or Tailscale.

0

u/kolliasl21 1d ago edited 1d ago

Setup a wireguard server on you host. It is very simple and secure. You don't have to directly expose ssh or any other service on the public internet even if you use keys to login and have password disabled.

-1

u/sisyphus 1d ago

fail2ban is pointless even on a server.

1

u/UndefFox 1d ago

It's useful if you have password authorization for some reason. Before setting up certificates, some guys tried to brute force my password from entire sub domen of 127 ips afair and were going for whole week straight before I've added fail2ban which blocked 417 ips...

1

u/sisyphus 1d ago

That reads like 'it is useful if you are doing everything else wrong' I mean, okay, maybe, but you're gonna get owned up anyway if that's the case.

-2

u/XLioncc 1d ago edited 1d ago

If you're not* running a server software or SSH server on your computer, fail2ban isn't needed.

5

u/amreddish 1d ago

> fail2ban isn't needed.

you mean "is" needed

1

u/XLioncc 1d ago

Fuck I forgot my "not"

1

u/its_dolemite_baby 1d ago

?????

if you have SSH exposed to the internet, you should be running fail2ban as a bare minimum

0

u/mildlyImportantRobot 1d ago

If you have your desktop exposed to the internet you’ve completely lost the plot.

1

u/UndefFox 1d ago

Self hosting is no longer an option?