Skip to content

fb_ssh: ensure /run/sshd exists before sshd_config verify#30

Closed
kcronin wants to merge 1 commit intomainfrom
fix-sshd-privsep-dir-noble
Closed

fb_ssh: ensure /run/sshd exists before sshd_config verify#30
kcronin wants to merge 1 commit intomainfrom
fix-sshd-privsep-dir-noble

Conversation

@kcronin
Copy link
Copy Markdown

@kcronin kcronin commented Mar 16, 2026

Summary

On Ubuntu 24.04, openssh 9.6p1 changed sshd -t (config-test mode) to require the privilege separation directory /run/sshd even when just testing configuration. This broke our Ubuntu 24.04 image builds starting Mar 16, 2026.

Root cause: When fb_ssh upgrades the openssh packages during a Chef run, the dpkg post-install scripts restart sshd asynchronously through systemd. Systemd removes /run/sshd (a RuntimeDirectory) when stopping sshd, and recreates it when starting. This creates a ~4-second window where /run/sshd doesn't exist. The sshd_config template verify (sshd -t) runs during this window and fails:

Proposed content for /etc/ssh/sshd_config failed verification /usr/sbin/sshd -t -f %{path}
STDERR: Missing privilege separation directory: /run/sshd

Fix: Add a directory[/run/sshd] resource directly before the sshd_config template. By the time Chef has executed the preceding resources (ruby_block, confdir directory, key file permissions), the sshd stop phase has already completed — so we're recreating the directory after the delete, not racing it.

This matches the approach discussed in facebook#58.

Test plan

  • Lint: cookstyle cookbooks/fb_ssh/recipes/default.rb — no offenses
  • Ubuntu 24.04 image build succeeds (validated via etsy/chef-config CI)

🤖 Generated with Claude Code

On Ubuntu 24.04, openssh 9.6p1 checks for the privilege separation
directory /run/sshd even in config-test (-t) mode. When the openssh
packages are upgraded during a Chef run, dpkg post-install scripts
restart sshd asynchronously via deb-systemd-invoke (bypassing
policy-rc.d), causing systemd to briefly remove /run/sshd (a
RuntimeDirectory) during the stop phase.

By the time Chef has run through the preceding resources (ruby_block,
confdir directory, key file resources), the stop phase has already
completed. Adding a directory resource here recreates /run/sshd so the
sshd_config template verify succeeds.

See: facebook#58

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kcronin kcronin closed this Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant