fb_ssh: ensure /run/sshd exists before sshd_config verify#30
Closed
fb_ssh: ensure /run/sshd exists before sshd_config verify#30
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Ubuntu 24.04, openssh 9.6p1 changed
sshd -t(config-test mode) to require the privilege separation directory/run/sshdeven when just testing configuration. This broke our Ubuntu 24.04 image builds starting Mar 16, 2026.Root cause: When
fb_sshupgrades the openssh packages during a Chef run, the dpkg post-install scripts restart sshd asynchronously through systemd. Systemd removes/run/sshd(aRuntimeDirectory) when stopping sshd, and recreates it when starting. This creates a ~4-second window where/run/sshddoesn't exist. Thesshd_configtemplate verify (sshd -t) runs during this window and fails:Fix: Add a
directory[/run/sshd]resource directly before thesshd_configtemplate. 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
cookstyle cookbooks/fb_ssh/recipes/default.rb— no offenses🤖 Generated with Claude Code