Repository navigation
Keep harden_ssh working when sshd is socket-activated - #860
Draft
antobinary wants to merge 1 commit into
Draft
antobinary wants to merge 1 commit into
antobinary wants to merge 1 commit into
Conversation
On Ubuntu 24.04 openssh-server is socket-activated. The dist-upgrade that runs earlier in the installer upgrades openssh-server, and that package's postinst only restarts ssh.socket. Restarting the socket stops ssh.service, and systemd removes the unit's RuntimeDirectory, /run/sshd, with it. The session running bbb-install survives (KillMode=process), so when harden_ssh later runs `sshd -t` there is no daemon and no /run/sshd, and sshd aborts with "Missing privilege separation directory: /run/sshd". harden_ssh then removes the hardening file and exits the installer with status 1, before the LTI/Greenlight, ImageMagick policy and final bbb-conf --check steps. Create /run/sshd before validating. systemd recreates and removes the directory on service start and stop anyway, so this is harmless when the daemon is already running. The restart fallback had the same blind spot: sshd.service is only an alias of ssh.service, and the alias is not installed while ssh.socket is what is enabled, so `systemctl restart sshd` fails there with "Unit sshd.service not found". The unit has been ssh.service on every Ubuntu release the installer supports. `systemctl try-restart ssh.service` restarts a running daemon and is a no-op for an idle socket-activated one, whose next connection starts it with the new config. Reproduced and verified on a fresh 24.04 droplet installing 4.0.
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.
On Ubuntu 24.04 openssh-server is socket-activated. The dist-upgrade that runs earlier in the installer upgrades openssh-server, and that package's postinst only restarts ssh.socket. Restarting the socket stops ssh.service, and systemd removes the unit's RuntimeDirectory, /run/sshd, with it. The session running bbb-install survives (KillMode=process), so when harden_ssh later runs
sshd -tthere is no daemon and no /run/sshd, and sshd aborts with "Missing privilege separation directory: /run/sshd". harden_ssh then removes the hardening file and exits the installer with status 1, before the LTI/Greenlight, ImageMagick policy and final bbb-conf --check steps.Create /run/sshd before validating. systemd recreates and removes the directory on service start and stop anyway, so this is harmless when the daemon is already running.
The restart fallback had the same blind spot: sshd.service is only an alias of ssh.service, and the alias is not installed while ssh.socket is what is enabled, so
systemctl restart sshdfails there with "Unit sshd.service not found". The unit has been ssh.service on every Ubuntu release the installer supports.systemctl try-restart ssh.servicerestarts a running daemon and is a no-op for an idle socket-activated one, whose next connection starts it with the new config.Reproduced and verified on a fresh 24.04 droplet installing 4.0.