by sph · 2y ago · 0 comments
% ssh example.com
Last failed login: Sun Jan 28 16:59:35 UTC 2024 from 180.101.88.233 on ssh:notty
There were 5385 failed login attempts since the last successful login.
Last login: Sat Jan 27 13:33:30 2024 from xxx.xxx.xxx.xxx
5.3k failed attempts in ~30 hours. I know, I should be setting up fail2ban.Ideally you don't need ssh open to the whole world anyway, and can restrict it to a certain subnet or set of addresses. Then your attacks will drop to nearly zero.
table inet filter {
chain input {
tcp dport ssh accept comment "Accept SSH"
tcp dport 22 ct state new limit rate over 2/minute drop
But even with rate limiting, the logs are still polluted by auth attempts. Changing the port does little. The only solution we found was to configure port knocking (with direct access from a few whitelisted IPs).Also I normally set up a jump host first - a smallest instance that only runs ssh and everything else would not open ssh port to the outside at all. One nice effect is having to search just one auth log if something about ssh looks concerning.
https://cloudonaut.io/connect-to-your-ec2-instance-using-ssh...
No, that does nothing if you followed best practices and disabled password login. fail2ban is just another Denial of Service risk that has the added bonus of bloating your firewall table and slowing down all your new connections