I'm trying to decrypt all of my ssh logs (in order to give them reasonable tags with logstash). But I have found one case that I dont really understand:
Oct 23 07:43:47 sshd[59830]: Connection from 74.194.6.5 port 60126 on 213.67.100.148 port 22
Oct 23 07:43:51 sshd[59830]: error: maximum authentication attempts exceeded for root from 74.194.6.5 port 60126 ssh2 [preauth]
Oct 23 07:43:51 sshd[59830]: Disconnecting authenticating user root 74.194.6.5 port 60126: Too many authentication failures [preauth]
How can it reach the maximum authentication attempts without giving any sign of a authentication attempt?
Usually I get things like before the "maximum auth..." row appears.
Oct 23 08:54:06 sshd[62392]: Failed keyboard-interactive/pam for [...]
Oct 23 08:52:41 sshd[49690]: Failed publickey for [...]
But not always.
Please note, I dont have problems logging in..
That error message gets triggered, among others, when the ssh client attempts a key-based login and offers more than
MaxAuthTries
invalid keys. The SSH server will then break off the connection. That can either be caused by a (malicious) client that has no valid keys at all, or by valid users who simply have many different key-pairs and theMaxAuthTries
number is reached before the valid key can get exchanged. When that happens the connection will be terminated and won't even reach the stage where alternative login methods are offered/attempted.(At the default log level) the ssh server doesn't record the failed keys get are exchanged and therefor the error message "
error: maximum authentication attempts exceeded for ... ssh2 [preauth]
" seems to appear without any prior authentication attempts in the log file.You can easily simulate that with:
The default value for
MaxAuthTries
is 6.Increasing the sshd_config
LogLevel
toVERBOSE
will generate the extra log events that make slightly more sense:According with the sshd config man page
As you can see, the limit is valid in a per connection basis and not all the attempts are logged. You can also choose how many information do you want in logs
In OpenSSH/Logging and Troubleshooting you can see examples of logs in which you can see that the rejecting part is similar to the one you have shown:
Summing it up, failed authentication attempts are not always sent to logs. The befaviour can be configured in the conf file for httpd.
And now, from my not very happy experience exposing ssh to the internet, let me give some general recomendations:
Another thing is if you want to login on root user by ssh using password and your config is set to
PermitRootLogin prohibit-password
it will end with errorerror: maximum authentication attempts exceeded for root from 10.0.12.12 port 58656 ssh2 [preauth]