I have searched the forum for similar discussions
on
I understand this category is for discussions, not support requests, and not for app requests.
on
This form is written in English but feel free to write in French if you’re more comfortable!
on
Discuss
recently I started to get daily warnings (mails of YH diagnosis) of this message
[WARNING] There’s been a suspiciously high number of authentication failures recently. You may want to make sure that fail2ban is running and is correctly configured, or use a custom port for SSH as explained in https://yunohost.org/security
I was wondering what’s going on, on the server and I was concerned.
Previously I did install the YH app fail2ban web interface and I hoped to find more information about how many attacker there are. I actually did my homework and change the SSH port. So I checked the web interface and there was not a single IP banned. So I asked myself how is this possible? It can’t be that bad then, I thought. I also thought maybe something was broken with fail2ban.
I’ve checked the YH fail2ban documentation but I couldn’t find more information about such situations.
Then I did some deep research on fail2ban (I’m not experienced in this) and found out that there are about 1500 attacks on my server daily (in total) on ssh (failed password/invalid user). That was kind of hard to find out and only with the use of AI. Apparently that number doesn’t generate active bans but is still considered as a high number. To me this is kinda contradicting. Apparently the attacker found out what the banning settings are and stay just below that number, so that they don’t get banned.
In any case, I know I could do some more aggressive banning like less maxretry, shorter findtime and longer bantime but the number of attacks don’t really hurt my VPS resources (network, CPU, RAM).
wouldn’t you also think that it would be good to provide the average YH user with a few more information on how to deal with the above diagnosis message?
Also, it might be interesting to know how many attacks would be considered as high for which environment (just a few examples). e.g. 1500 attacks per day = 1 per minute, in average. I would say that’s a low number, even for a Raspberry Pi.
I had mostly ssh attacks and a few postfix (mail).
If someone is interested on how to find out more information on the attacks on a Yunohost server, here are a few commands for the terminal. It should possible to paste a complete code block in the terminal (it was at least for me)
Number of password attacks in the last 24h
sudo journalctl -u ssh --since "24 hours ago" --no-pager \
| grep -Ec 'Failed password|Invalid user'
Successfull logins in the last 7 days
sudo journalctl -u ssh --since "7 days ago" \
| grep -E 'Accepted (password|publickey)'
Some fail2ban settings
sudo fail2ban-client get sshd maxretry
sudo fail2ban-client get sshd findtime
sudo fail2ban-client get sshd bantime
sudo nano /etc/fail2ban/jail.conf # changing those settings
cd /etc/fail2ban/jail.d/ # conf files - jails and whitelists
Top 20 attacker in the last 24h with the number of attacks
sudo journalctl -u ssh --since "24 hours ago" --no-pager \
| grep -E 'Failed password|Invalid user' \
| grep -oP 'from \K[0-9a-fA-F:.]+' \
| sort | uniq -c | sort -nr | head -20
Ban several IP’s / “top attacker” at once, permanently (with blank between the IPs)
that will probably not help that much since the attacker may get a different IP after 24h, at the latest.
sudo fail2ban-client set sshd banip 10.10.10.1 10.10.10.2 10.10.10.3