code · Nov 12, 2026

sshd: PasswordAuthentication no has no effect

why does PasswordAuthentication no in sshd_config not work on Debian/Ubuntu cloud servers and where to place the setting

Symptom: `PasswordAuthentication no` is appended to `/etc/ssh/sshd_config`, sshd reloaded, and password logins still work. Cause: Debian and Ubuntu ship `Include /etc/ssh/sshd_config.d/*.conf` near the top of the main file. sshd applies the first value it reads for a keyword, so a cloud-init drop-in such as `50-cloud-init.conf` with `PasswordAuthentication yes` wins over everything further down. Source position in the main file does not matter, evaluation order does. Fix: a drop-in that sorts first. ``` # /etc/ssh/sshd_config.d/01-hardening.conf PasswordAuthentication no KbdInteractiveAuthentication no PubkeyAuthentication yes PermitRootLogin prohibit-password ``` `01-` sorts before `50-cloud-init.conf`; keep it root-owned, mode 644. `sshd -t` and `sshd -T` read the configuration files, they never query the daemon. A clean run proves the files are valid, not that the service uses them. Roll out in this order: 1. `sshd -t` validates the files. 2. Keep the current session open. 3. `systemctl reload ssh`, then check `systemctl status ssh --no-pager` and `journalctl -u ssh -n 20`. A failed reload leaves the old configuration running. 4. Open a new session and log in with your key. 5. Prove the refusal: `ssh -o PubkeyAuthentication=no -o PreferredAuthentications=password user@host` must be rejected. 6. For Match blocks test the concrete connection: `sshd -T -C user=root,host=<client-name>,addr=<client-ip>`; `host` is the client's resolved name, not the server's.

Check your SSH login settings

See the effective SSH authentication settings for a user and client address. Includes an offline demo. Requires Python and OpenSSH.

Download SSH Password Check (ZIP)

Query directly via MCP

This blueprint is also machine-readable: Markdown. Create an API key without an account:

curl -sS -X POST https://solvedlist.com/api/v1/keys \
  -H 'Content-Type: application/json' -d '{"note":"agent"}'
POST https://solvedlist.com/mcp
Authorization: Bearer ***
Content-Type: application/json

{"jsonrpc":"2.0","id":1,"method":"tools/call",
 "params":{"name":"solvedlist_lookup","arguments":{"question":"…"}}}

More: /llms.txt · /openapi.json