Fail2Ban
github.com
github.com
That leaves noise in the logs - which sure, it's nice to reduce, but using an alternative port can help here.
I may sound like a spoilsport - but the fact that there have been a number of security vulnerabilities (https://www.cvedetails.com/vulnerability-list/vendor_id-5567...) in this project, make it worse than security theatre, it actually increases risk whilst not at all reducing it.
Don't use fail2ban. (Don't use passwords, either!)
https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu...
Brute force / credential stuffing attacks against ssh are the mosquitos of the Internet.
Ubiquitous, annoying, and persistent. But nothing personal.
A personal insult, if you are ever unfortunate enough to receive one, will be much more stealthy and neither fail2ban nor any other magical rock will protect you against it.
Available in `xtables-addons` it seems. After install:
iptables -A INPUT -p tcp -s $SOURCE_IP -j TARPIT # add IP to tarpit
iptables -D INPUT -p tcp -s $SOURCE_IP -j TARPIT # remove IP from tarpitAnyone who manages servers professionally does not read logs anymore and does not care about obvious things like people brute-forcing.
Reading ssh logs on your single VPS is security LARPING. Discussing faill2ban as well :)
In world where "login attempts" are basically all day reality reading logs is meaningless. In 2023 no one should be reading logs you should have alerts on events. In 1995 or something if someone was trying to brute-force your user password that was security event to look at and block IP. In 2023 someone brute-forcing is not an event, it is either wrong configuration like not using ssh authentication or not using tools that filter logs automatically and make alerts when something is actually going on.
More general, some attacker actions, especially during recon, rely on making many attempts to connect, fetch an URL, resolve FQDN, etc., these could be detected and automatically responded to, making attacker’s job harder and providing extra visibility to defenders.
Citation needed for the claim “has been attacked” if you refer to real attacks in the wild.
While it’s a nice trick, it’s simply not relevant. And the vulnerability before that seems to be 10 years old. I’d say it’s a decent track record.
To tptacek's point, you've got to ask yourself is a denial of service attack in your threat model?
The reality is most folk set up fail2ban after seeing auth failures in their logs, not service degradation.
If you're considering a denial of service attack in your threat model, then I'd probably also consider a DDoS attack and there are likely more effective solutions here (a firewall or CDN).
And don't forget you're using some of those precious CPU cycles to parse the auth logs, with python no less :-)
You can ship the log somewhere else, do the fail2ban there and perform the block action in another place up the stack.
I'm not so sure that's a good reason to be honest. And if you're worried about CVE's, well, you'll be using handwritten, hand delivered notes before long. Keep your systems patched, keep them tidy, none of this is likely to affect you, fail2ban or not.
Particularly on my small server, fail2ban is the difference between "usable" and "on the edge of falling over".
Everyone makes mistakes. That’s the whole point of the Swiss cheese model and of layers of security in general.
I look at the imap login attempts on my server sometimes. The passwords they try are usually pathetic. Nothing close to the 15+ character actual passwords we have in use.
I disagree with this, 404 queries still use resources and someone trying URLs in a matter of seconds should be blocked nonetheless.
Only if you can get business/users/management buy-in or approval for implementing those ways and changing workflows.
No, it cannot. As a sysadmin I do not want to get into user training about telling people about alternative ports and tweaking their CLI habits and any scripts that they have.
If you want to further cut down on the log noise get an IPv6 address (and drop IPv4)—good luck to anyone trying to scan a /64 for open ports.
Even if I make no effort at all to hide things and just select xxxx:xxxx:xxxx:1:: as the subnet (leaving a factor 65535 options on the table) the devices behind it will randomize the next 64 bits meaning you'll have to scan 18 quintillion (1.8e19) addresses to find one.
(Blocks always have to do with saved passwords being used from a nonwhitelisted IP)
Shifting services to alternate port numbers will stop very stupid scanners but it does not stop the worst offenders IME. Basically it just means you'll only get the really obnoxious sources that try everything ignoring responses.
> I may sound like a spoilsport - but the fact that there have been a number of security vulnerabilities (https://www.cvedetails.com/vulnerability-list/vendor_id-5567...) in this project, make it worse than security theatre, it actually increases risk whilst not at all reducing it.
Given the age of the project and that there's been a whopping NINE vulnerabilities found in its lifetime, this is a great take. By this same logic you better disable OpenSSH everywhere. In the same timeframe as Fail2Ban has has reported vulnerabilities, OpenSSH has had at least 60: https://www.cvedetails.com/vulnerability-list/vendor_id-97/p...
"Worse than security theatre" is quite the statement given they reported and fixed those issues in timely fashions.
If you apply the principles of defense in depth, using the network layer to deny access to misbehaving remote hosts is an obvious win on a lot of fronts and hardly qualifies as security theatre anymore than using a network firewall is security theatre.
Failed login attempts (the noise) are not where bad things happen. What we should be concerned with is if the attempt succeeds but is not from a legitimate user. fail2ban is no help there.
Having said that it might be a decent way to collect IPs. At one point I was distributing the collected IPs from VMs and blocking them for the whole network. fail2ban does provide mechanisms to do this.
It does not protect against anything serious: you must have proper credentials/MFA or certificates and therefore bots can check as much as they want.
There is no protection against DoS either.
And I agree about moving the port - I only see a tiny activity in my logs coming from bots when my ssh port moved away. Obviously 443 is there to stay (this is a public service) so I will get whatever comes.
Brute.Fail: Watch brute force attacks fail in real time - https://news.ycombinator.com/item?id=36169954 - June 2023 (259 comments)
Ask HN: How to protect against endless SSH login attempts to my server? - https://news.ycombinator.com/item?id=34077205 - Dec 2022 (27 comments)
The corporate scanner are not there for fun or because security loves to do scans. They are there exactly because they are random wannabe sysadmins who will plug in a box that ends up compromised.
A scanner may help to locate it and possibly warn about the issue. And only maybe.
Do not make life difficult for people who already have they hands full of constant vulnerabilities, fighting corporate crap and being the bad guys because they audit stuff.
We have a life too.
Found this alternative:
On another host I tried port 443, hoping to disguise it to appear like SSL. No any difference.
Also, there are services, which already publishing all my (and yours) open ports. Here is the report for my IP:
https://search.censys.io/hosts/104.63.172.143 (It's public anyway)
Shockingly it still works fine on Server 2022.
I have friends of mine that slowly migrated to ZeroTier for RDP.
Make yourself a vpn box or some Linux with ssh and do port forwarding and allow RDP from that Linux host. OpenVpn or ssh are much better to be exposed to the internet.
If for some reason you still needed password auth enabled I'd be inclined to still use f2b.
If I lose access by, say, switching to a new computer and losing my SSH key, then I'm more or less dead in the water. But it's a small price to pay and 1password supports SSH keys first-class now.
This gives sufficient notice to fix things if a key were to become compromised.
You can white list specific IPs though
This is what I mean, if this list can be dynamic or modified at runtime with an API.
Silly examples but the bots get confused. I admit these are not efficient rules. Try it out on that domain. Send some SSH bots my way, I honestly have no idea what it looks like on the bot-end-of-things. I would estimate about 95% of bots are libssh. About 4% are Go and the rest are an odd mix. That string can be spoofed but I think most people are too lazy.
sudo apt install fail2ban # Choose your flavour
And you get rid of most pesky SSH knocking traffic and credential stuffing attacks.
I wonder if SSO services can provide IPs of successfully authenticated against their services users.
Having had a very bad experience with getting my home network once DDoSed and once hacked - I am at a stage where a reliable third party source, that can tell me what IP to whitelist, is the only reasonable solution I can come up with. (I know it's not a common use case, but it is my use case)
The problem with fail2ban is that an attacker who has a botnet of significant size at their disposal won't even be slowed down. Not saying it's worthless, but it's not a silver bullet.
100%. These days, at least if you're working out of a cloud provider, there's no excuse for exposing SSH to the world on any port. AWS/GCP/Azure all have different tools to allow you to run bastion-type services without internet-facing SSH.
This is explicitly made an example here: https://ico.org.uk/for-organisations/uk-gdpr-guidance-and-re...
Secondly, consent is only one of six legal bases for processing personal data. The other five are that:
- processing is necessary for the performance of a contract to which the data subject is party or in order to take steps at the request of the data subject prior to entering into a contract;
- processing is necessary for compliance with a legal obligation to which the controller is subject;
- processing is necessary in order to protect the vital interests of the data subject or of another natural person;
- processing is necessary for the performance of a task carried out in the public interest or in the exercise of official authority vested in the controller; and
- processing is necessary for the purposes of the legitimate interests pursued by the controller or by a third party, except where such interests are overridden by the interests or fundamental rights and freedoms of the data subject which require protection of personal data.
The last of those - legitimate interests - is clearly appropriate, the rights of the data subjects (i.e. the IP addresses' users) don't override the legitimate interests of securing one's machines, especially given the limited processing performed by tools like Fail2Ban.