passwordauthentication yes. That was the server’s answer, printed by sshd -T, one line after the last line of sshd_config had been changed to say PasswordAuthentication no. The edit was correct, the file was saved, the syntax test passed, and the server would still have accepted passwords from anyone on the internet who guessed one. The reason sat in a different file.
The walkthrough below was run end to end on an Ubuntu 24.04 test container with OpenSSH 9.6p1: a second sshd was started on port 2226 with a copy of Ubuntu’s stock config, and a test user logged in to it over localhost. Client and server were the same machine, so network behavior such as firewalls and NAT was not tested. Fingerprints and dates are trimmed from the output.
Generate an Ed25519 key with a passphrase
One command, and the defaults have finally caught up
Run this on the machine that will do the connecting, not on the server:
$ ssh-keygen -t ed25519 -a 100 -C "laptop-2026"
Generating public/private ed25519 key pair.
Your identification has been saved in /home/labuser6/.ssh/id_ed25519
Your public key has been saved in /home/labuser6/.ssh/id_ed25519.pub
$ ls -l ~/.ssh
-rw------- 1 labuser6 labuser6 444 id_ed25519
-rw-r--r-- 1 labuser6 labuser6 93 id_ed25519.pub
Ed25519 has been in OpenSSH since version 6.5, whose release notes describe it as a scheme “that offers better security than ECDSA and DSA and good performance” (OpenSSH 6.5 release notes). Since OpenSSH 9.5, released 2023-10-04, ssh-keygen generates Ed25519 keys by default (OpenSSH 9.5 release notes). The test container agreed: ssh-keygen with no -t flag produced a ssh-ed25519 public key. The -t ed25519 is still worth typing, because older servers and old habits linger.
The -a flag sets key-derivation rounds that protect the private key file if it is stolen. The ssh-keygen manual says higher values give “increased resistance to brute-force password cracking,” at the cost of a slower unlock. OpenSSH 10.6, released 2026-10-06, raised the default from 24 to 32 rounds (OpenSSH release notes). Set a passphrase. A private key without one is a house key taped to the doormat, and the manual’s advice is a phrase of 10 to 30 characters that is not a simple sentence.
The .pub file is safe to hand out. The other one is not, and the manual notes the private key “should not be readable by anyone but the user.”

Put the public key on the server
ssh-copy-id does the tedious part, and the permissions it sets matter
ssh-copy-id logs in with a password one last time, appends the public key to ~/.ssh/authorized_keys on the server, and sets the file modes. Against the test server, for a second account named labsrv6:
$ ssh-copy-id -i ~/.ssh/id_ed25519.pub -p 2226 labsrv6@127.0.0.1
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/labuser6/.ssh/id_ed25519.pub"
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Number of key(s) added: 1
$ stat -c '%a %n' /home/labsrv6/.ssh /home/labsrv6/.ssh/authorized_keys
700 /home/labsrv6/.ssh
600 /home/labsrv6/.ssh/authorized_keys
Without ssh-copy-id, paste the single line from id_ed25519.pub into ~/.ssh/authorized_keys on the server and set the same modes, 700 on the directory and 600 on the file. Before this step, the test server’s refusal listed both doors it would open:
labuser6@127.0.0.1: Permission denied (publickey,password).
That parenthesis is a quick audit tool. Whatever appears in it is an authentication method the server will accept right now.
ssh-agent and ~/.ssh/config
Type the passphrase once per session, and stop typing hostnames and ports
A passphrase on every connection gets old by lunch, and tired people remove passphrases. ssh-agent holds the unlocked key in memory so the passphrase is entered once:
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_ed25519
Identity added: /home/labuser6/.ssh/id_ed25519 (laptop-2026)
$ ssh-add -l
256 SHA256:<fingerprint> laptop-2026 (ED25519)
Then give the server a short name in ~/.ssh/config (mode 600):
Host lab
HostName 127.0.0.1
Port 2226
User labuser6
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
IdentitiesOnly yes tells the client to use only the configured key, even when the agent holds many; the ssh_config manual says it exists for situations “where ssh-agent offers many different identities.” The sshd_config manual sets MaxAuthTries at 6 attempts per connection by default. On the test box, an agent loaded with six throwaway keys plus the real one, added last, never got that far:
keys in agent: 7
Offering public key: ... (6 times)
Received disconnect from 127.0.0.1 port 2226:2: Too many authentication failures
With IdentitiesOnly yes and the Host lab block, the same agent logged straight in. Order matters too. The same manual says the first value obtained for each option wins, so specific Host blocks go near the top and a catch-all Host * goes at the bottom.
With the key installed, ssh lab connected, and the verbose log showed the handshake:
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: /home/labuser6/.ssh/id_ed25519 ED25519 SHA256:<fp> explicit agent
debug1: Server accepts key: /home/labuser6/.ssh/id_ed25519 ED25519 SHA256:<fp> explicit agent
Authenticated to 127.0.0.1 ([127.0.0.1]:2226) using "publickey".
Keys work. Passwords still work too, and that is the job of the next step.

Disable password login without locking yourself out
Keep one door open until the new lock has been tried from the outside
The safe order is boring and should stay boring:
- Keep a working SSH session open the whole time. It is the rope tied to the ladder.
- Confirm a key login works in a second terminal.
- Change the config, then run
sudo sshd -t(syntax check) andsudo sshd -T | grep -E 'passwordauth|kbdinteractive'(effective values). - Reload the service. The sshd manual says the daemon “rereads its configuration file when it receives a hangup signal,” and it forks a separate process for each connection.
- Open a third terminal and log in again before closing anything.
Now the trap from the opening. Near the top of Ubuntu’s sshd_config, on line 12 of the stock file on the test container, sits Include /etc/ssh/sshd_config.d/*.conf. The sshd_config manual states that “for each keyword, the first obtained value will be used.” Anything in the drop-in directory is read before the rest of the main file, so it wins. On Ubuntu Server, cloud-init can write a one-line /etc/ssh/sshd_config.d/50-cloud-init.conf containing PasswordAuthentication yes. A 2024 Ubuntu bug report, titled “cloud-init enables ssh password auth in an unexpected config file,” describes exactly that file on a 24.04 server installed from the ISO, overriding a PasswordAuthentication no in the main config.
The test reproduced it with the same file name:
# 50-cloud-init.conf says yes, last line of sshd_config says no
$ sshd -T -f sshd_config | grep ^passwordauthentication
passwordauthentication yes
# add 01-hardening.conf containing "PasswordAuthentication no"
$ sshd -T -f sshd_config | grep ^passwordauthentication
passwordauthentication no
A drop-in named 01-hardening.conf sorts before 50-cloud-init.conf, so its value is read first and sticks. The manual confirms that wildcard includes expand in lexical order. Put both settings in it:
PasswordAuthentication no
KbdInteractiveAuthentication no
The second line matters because keyboard-interactive is a separate method that can also ask for a password, and the manual says it is allowed by default. Ubuntu’s stock file already sets it to no; a hand-built server might not. Root logins are a third setting: the manual gives prohibit-password as the default for PermitRootLogin, which blocks root passwords but still allows a root key.
After the reload, a client that offered no key got the short answer:
labuser6@127.0.0.1: Permission denied (publickey).
And the key login still went through: ssh lab "echo still in" printed still in.
Where people get burned
Most lockouts come from file permissions and file order, not from cryptography
- The drop-in that overrides the edit. Shown above. Always confirm with
sshd -T, which prints the effective config, rather than reading the file and trusting it. - Home directory permissions.
sshdchecks the modes of the user’s files and home directory before accepting a key whenStrictModesis on, which the manual lists as the default. On the test box,chmod 777on the home directory broke key login instantly: the client gotPermission denied (publickey)and the server’s auth log saidAuthentication refused: bad ownership or modes for directory /home/labuser6. Setting the directory back to 750 restored access. - What did not break. A group-writable
authorized_keys(mode 664) still worked on this Ubuntu build, where the user’s group contains only that user. Other setups may reject it. Use 600 and stop guessing. - A passphrase-protected key in a script. In
BatchMode, with no agent running, the test login failed withPermission denied (publickey), because nothing could type the passphrase. Automation needs its own key, restricted on the server side, not the laptop key with its passphrase stripped. Replication jobs such as thezfs send ... | ssh host zfs receivepipeline in the x9m8 ZFS home NAS guide are exactly that kind of automation. - One key, one laptop. If that laptop dies and password login is off, the only remaining door is the provider’s console. Install a second key from a second device before step 3.

The case for leaving passwords on
A strong password plus rate limits is not nothing, and keys bring their own failure modes
A long random password on a server behind a firewall, with a tool such as fail2ban banning repeat offenders, is very hard to brute-force, and that is the best argument against this post’s advice. Keys, meanwhile, live on laptops that get stolen, backed up to cloud drives, and copied to new machines without anyone tracking where they went. A server can have dozens of forgotten lines in authorized_keys, and every one of them is a working key.
All true. Password authentication still accepts guesses from anyone who can reach the port, though, and the private half of a key never leaves the client, so a phished or reused password is useless against a key-only box. The honest fix for key sprawl is housekeeping: a comment on every key (-C exists for that), one key per device, and a yearly read of authorized_keys that deletes anything nobody can name. Narrowing who can reach port 22 in the first place, with a host firewall or a private tunnel such as the one in the x9m8 WireGuard home VPN guide, shrinks the problem further.
On the test server, the line that started all this was one character long in the wrong file. How many machines on a home network are still printing passwordauthentication yes right now, with an owner who swears they turned it off?
Sources
- OpenSSH 6.5 release notes: https://www.openssh.org/txt/release-6.5
- OpenSSH 9.5 release notes: https://www.openssh.org/txt/release-9.5
- OpenSSH release notes (10.6 KDF rounds change): https://www.openssh.org/releasenotes.html
- ssh-keygen(1) manual: https://man.openbsd.org/ssh-keygen
- ssh_config(5) manual: https://man.openbsd.org/ssh_config
- sshd_config(5) manual: https://man.openbsd.org/sshd_config
- sshd(8) manual: https://man.openbsd.org/sshd
- Ubuntu bug 2088207 mailing-list record, November 2024: https://lists.snapcraft.io/archives/foundations-bugs/2024-November/527297.html
- Test output: Ubuntu 24.04 container, OpenSSH 9.6p1 client and server on localhost port 2226 (run for this post)
