SSH allows many authentication tries
- Check
ssh.max_auth_tries- Severity
- low
- Runs
- on the server, in the daily run of the agent
- Looks at
- MaxAuthTries above 6
What the check looks at
The agent reads MaxAuthTries from the effective sshd configuration (sshd -T) and warns when it is above 6,
the OpenSSH default.
Why it matters
MaxAuthTries is the number of authentication attempts sshd allows on one connection before it closes it.
Each password a bot tries and each key a client offers counts. A high value gives a password-guessing bot more
tries per connection, so it can guess faster before fail2ban, CrowdSec or the built-in penalties of OpenSSH
9.8 and later react. With key-only login the value matters less, which is why the severity is low.
How to fix it
Set a lower value in a drop-in file. sshd keeps the first value it reads, so the file name starts with a low
number. On RHEL 8, Rocky Linux 8 and AlmaLinux 8, sshd_config does not read /etc/ssh/sshd_config.d/; add the
Include line at the top of it first, as the SSH hardening guide shows.
echo 'MaxAuthTries 3' | sudo tee /etc/ssh/sshd_config.d/10-maxauthtries.conf
sudo sshd -t
Remove other MaxAuthTries lines so the configuration stays readable:
sudo grep -rn MaxAuthTries /etc/ssh/sshd_config /etc/ssh/sshd_config.d/
Reload sshd:
Debian and Ubuntu
sudo systemctl reload ssh
RHEL, Rocky Linux and AlmaLinux
sudo systemctl reload sshd
Alpine
sudo rc-service sshd reload
A client with many keys in its SSH agent can fail with Too many authentication failures before it
reaches the right key. Tell the client which key to use, in ~/.ssh/config on the workstation:
Host myserver
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
How to check the fix
sudo sshd -T | grep '^maxauthtries'
The output must be maxauthtries 3 (or the value you chose, 6 at most).
When a warning is fine
Rarely. If a client offers many keys, for example an automation tool that loops over keys, fix the
client with IdentitiesOnly and IdentityFile instead of raising the limit.
Sources
- sshd_config(5) —
MaxAuthTries, default 6 - ssh_config(5) —
IdentitiesOnly,IdentityFile