Skip to content

ENT-13766: Fix sshd hardening being overridden by drop-in configs#2136

Open
larsewi wants to merge 3 commits intocfengine:masterfrom
larsewi:directives
Open

ENT-13766: Fix sshd hardening being overridden by drop-in configs#2136
larsewi wants to merge 3 commits intocfengine:masterfrom
larsewi:directives

Conversation

@larsewi
Copy link
Contributor

@larsewi larsewi commented Mar 10, 2026

On Ubuntu, /etc/ssh/sshd_config includes drop-in files from sshd_config.d/ near the top, and OpenSSH uses first-match-wins. The previous policy only edited the main sshd_config, so drop-ins like 50-cloud-init.conf setting PasswordAuthentication yes took precedence.

Changes:

  • Add sshd_hardening_directives slist to avoid repeating directive names
  • Comment out insecure values recursively across /etc/ssh (main config and all drop-ins), not just sshd_config
  • Prepend hardening directives to the top of sshd_config, before the Include directive, so they take precedence over any drop-in

Ticket: ENT-13766
Signed-off-by: Lars Erik Wik lars.erik.wik@northern.tech

On Ubuntu, /etc/ssh/sshd_config includes drop-in files from
sshd_config.d/ near the top, and OpenSSH uses first-match-wins. The
previous policy only edited the main sshd_config, so drop-ins like
50-cloud-init.conf setting PasswordAuthentication yes took precedence.

Changes:
- Add sshd_hardening_directives slist to avoid repeating directive names
- Comment out insecure values recursively across /etc/ssh (main config
  and all drop-ins), not just sshd_config
- Prepend hardening directives to the top of sshd_config, before the
  Include directive, so they take precedence over any drop-in

Ticket: ENT-13766
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Ticket: ENT-13766
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
@larsewi larsewi requested a review from nickanderson March 10, 2026 12:22
On Ubuntu/Debian, the service is called ssh, not sshd.

Ticket: ENT-13766
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant