Repository navigation
Harden sshd: localhost bind, key before listen - #12099
chessing234 wants to merge 5 commits into
Conversation
Fold key-before-listen ordering from omacom#8365 onto the localhost bind from omacom#11513 so a rejected key never enables sshd.
Write localhost bind and PasswordAuthentication no before enable --now so the first listen is never password-open or world-reachable.
51bf446 to
89e20be
Compare
Automated AI review
Verified: the key-before-listen reordering closes the gap from #8363. With The main issue is that the new order fails on machines where sshd has never started. The loopback-only default is also a larger behavior change than the rest of the repository reflects. Setup fails when sshd has never started (no host keys yet)
Observed in an isolated run with real OpenSSH 10.5p1 against a private config tree, all privileged commands stubbed, and the unit's key-generation step modelled: with a valid key through Impact: Setup > Security > SSHD fails on fresh installs and after a factory reset, wherever sshd has not run yet, and its messages blame the drop-ins rather than the missing host keys. The shell test cannot see this because its Suggested change: generate host keys before validating, for example Loopback-only default removes remote access; the rest of the repository still assumes itAfter setup, sshd listens only on Places that still describe or depend on remote access:
Impact: the command that exists to enable SSH access produces a server no other machine can reach. For #8248, the omarchy-iso unattended path still enables sshd on all interfaces with Suggested change: whether loopback should be the default is a maintainer decision. If it is, update the summary, success message, manuals, acceptance test, removal command and callers above together. If not, keep remote access as the default and offer loopback as an explicit option. "Localhost bind only" is printed without being checked
Impact: the command can report a loopback-only server while sshd's effective config still listens on all addresses. Suggested change: check the effective listeners with A failed re-run leaves the loopback drop-in for the next restartThe Impact: the next sshd restart (a reboot, or Arch's Suggested change: remove the Key validation before install: Optional test improvement: the repository test passes at head (6 checks) and at base, and the head test does fail against the base script, so the reordering is detected. Three gaps showed up with mutants of the head script:
The runtime firewall assertion cannot fail: no stub logs ufw calls, and the Related work: open drafts #9463 and #9474 (#9474 contains #9463) rewrite the same setup path with the same ordering goal and conflict with this PR in both files. #9307 conflicts in the script and #9506 in the test. Review informationTest scope: head AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
|
generate host keys with ssh-keygen -A before sshd -t, verify listenaddress via sshd -T, and remove the localhost drop-in if password hardening fails later. |
Automated AI review
Follow-up to the earlier review and the author's reply, checked at head Outcome: two earlier findings are resolved and the other five remain. The new
Verified:
Of the author's three reply points, host-key generation and drop-in removal hold as described. The The listener check tests presence, not exclusivity
In the Impact: the command can still report a loopback-only server while sshd also listens on non-loopback addresses. The red "sshd is not listening on loopback only" message describes a check the code does not perform. Suggested change: reject any listener that is not loopback. For example, fail when the following filter is non-empty (tested only on captured grep -Ei '^listenaddress[[:space:]]' <<<"$effective_config" |
grep -Eiv '^listenaddress[[:space:]]+(127\.0\.0\.1|\[::1\]):[0-9]+$'It is empty for the stock, fresh-install and The repository test fails at this head and runs the real
|
closing in favor of #9463 (also integrated by #9474), whose current source validates key-only access before starting sshd and preserves prior configuration during rollback. this branch still has listener-exclusivity and failed-rerun bugs, and its loopback-only default conflicts with remote setup; the previous passing-test claim is withdrawn because the test lacks a host-key-generation stub and its daemon output no longer matches the implementation.
#8363 is covered by the older contribution; the broader policy in #8248 remains a separate decision. i inspected the current implementation but did not replay its native VM validation.