boup.
FR EN

Disable SSH password authentication on Ubuntu (cloud-init)

CheatsheetHomelabLinuxCheatsheet
On this page

Context

While installing an Ubuntu VM on Proxmox, I had trouble disabling SSH password authentication. Even though I had set PasswordAuthentication to no in /etc/ssh/sshd_config and restarted the sshd service, password authentication was still possible.

Cause

All the files in the /etc/ssh/sshd_config.d/ directory are included in the /etc/ssh/sshd_config configuration through the following line:

text
Include /etc/ssh/sshd_config.d/*.conf

This directory contains 50-cloud-init.conf, related to the Ubuntu cloud-init tool, with the line:

text
PasswordAuthentication yes

You therefore need to comment out that line and restart SSH.

text
#PasswordAuthentication yes

Source

https://askubuntu.com/questions/1440290/unable-to-disable-password-authentication-over-ssh