brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: MaxAuthTries limits password guesses per SSH connection

Network and access
~/tips/tip-ssh-maxauthtries

MaxAuthTries 3

Lowers how many authentication attempts sshd allows per connection, default 6.

Six tries per connection sounds generous for a typo. For a bot guessing passwords it is six guesses on every connection it opens.

MaxAuthTries in sshd_config sets the maximum number of authentication attempts per connection. The default is 6, and once the failures reach half of that value, further failures are logged.

# /etc/ssh/sshd_config.d/10-limits.conf
MaxAuthTries 3

Before you reload, test the file, and keep your current session open until a new login works:

sudo sshd -t
sudo systemctl reload ssh

On some distributions the service is called sshd instead of ssh. To see what the daemon really uses after the reload, ask it:

sudo sshd -T | grep -i maxauthtries

The limit applies per connection, so a bot can open a new one and start counting again. It works as a small brake and nothing more. If you can, switch off password logins altogether and let keys do the work, and set this value low as an extra layer. On a server that still allows passwords, 3 is a sensible number to start from.

A low value also applies to you. If you mistype a password three times in a row, the server closes that connection and you have to start a new one.

Further reading: sshd_config(5)

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link