I'm seeing a lot of logs like these in /var/log/auth.log
(Debian Buster):
Jan 2 17:10:17 mybox sshd[16304]: Received disconnect from 1.2.3.4 port 37792:11: Bye Bye [preauth]
Jan 2 17:10:17 mybox sshd[16304]: Disconnected from authenticating user root 1.2.3.4 port 37792 [preauth]
Jan 2 17:10:20 mybox sshd[16306]: Received disconnect from 5.6.7.8 port 63061:11: Bye Bye [preauth]
Jan 2 17:10:20 mybox sshd[16306]: Disconnected from authenticating user root 5.6.7.8 port 63061 [preauth]
Jan 2 17:12:38 mybox sshd[16380]: Received disconnect from 9.10.11.12 port 55224:11: Normal Shutdown, Thank you for playing [preauth]
Jan 2 17:12:38 mybox sshd[16380]: Disconnected from authenticating user root 9.10.11.12 port 55224 [preauth]
I know these are attempts to break in, because no one should be attempting to log in that machine (other than me).
There is no corresponding rule in /etc/fail2ban/filter.d/sshd.conf
, so these attempts don't cause fail2ban to ban the offending IP address.
I have disabled password login, so I guess that what happens here is these attempts are dropped before they even attempt to authenticate, and for that reason fail2ban is not picking them up.
However, since I know these are break in attempts, I would still like to ban the IP, to stop them trying other things and filling up my logs.
Is it safe for me to add a Regexp matching some of those lines, or would I risk matching legitimate (key based) login attempts ? Which parts would make a safe combination ? Would matching the words "Disconnected" and the tag "[preauth]" necessarily indicate a failed password-based brute force ?