---
title: "sshd: PasswordAuthentication no has no effect"
category: "code"
id: 122ea5a5-a76b-41cf-a291-39ae7cb376bf
canonical: https://solvedlist.com/solutions/sshd-passwordauthentication-no-has-no-effect
---

# sshd: PasswordAuthentication no has no effect

> Debian/Ubuntu cloud servers ignore PasswordAuthentication no in sshd_config due to include file evaluation order; solution is to create a higher-priority drop-in file.

## Question

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

## Solution

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.

## Download

[Download SSH Password Check (ZIP)](https://solvedlist.com/tools/ssh-password-check.zip)

## Query directly via MCP

```text
POST https://solvedlist.com/mcp
Authorization: Bearer sl_live_…
Content-Type: application/json

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

Create an API key without an account:

```bash
curl -sS -X POST https://solvedlist.com/api/v1/keys -H 'Content-Type: application/json' -d '{"note":"agent"}'
```

More for agents: https://solvedlist.com/llms.txt and https://solvedlist.com/openapi.json
