Repository navigation
Start sshd and open its port only once a key is authorized - #14667
Conversation
The setup command enabled sshd and opened port 22 before asking for a key, so a cancelled prompt, a rejected key or a GitHub user with no keys left a reachable server accepting passwords. It now installs openssh and generates host keys, authorizes the key, writes and verifies the hardening drop-in, and only then enables sshd and opens the firewall. Host keys are generated up front because sshd -t refuses to validate without them, and on a fresh machine they would otherwise first appear when the server starts. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The PR appears safe to merge, with the previous test gap fixed and no new actionable issues found. SummarySSH setup now authorizes a key and checks password restrictions before starting
|
|
Heads-up on overlap: #14910 ("Validate key-only SSH setup before exposing the service") and the older #9463 both target #8363 with the same "nothing listens until a key is authorized" ordering, and #14781 is stacked on this branch for the host-key ordering test. It would help reviewers to agree on one of #14667/#14910 and fold #14781 into it. Greptile's point that the test checks |
|
Read the diff at 4b0aedf against current The classification is not settled yet: the second model (Codex Medium) was not asked, because today's review budget is spent. So this pull request has no class label, and nothing was run on a worker; the reproduction and test suite wait for the next pass, when both models can look at it. Related, for whoever picks between them: #14910 makes the same "nothing listens until a key is authorized" change with a larger rewrite (staged config with rollback, all-or-nothing GitHub key batches), and draft #9463 covers it as part of a much wider security change. #14781 is stacked on this branch and makes the test check that Waiting on the next review pass. |
sshd -t and sshd -T exit without host keys, so on a fresh install setup only works if ssh-keygen -A runs first. The test only checked that ssh-keygen ran at all. The sshd stub now refuses to run until it has. Co-authored-by: Donald Dunsmore <215750096+thebytorsnowdog@users.noreply.github.com>
On quattro the prompt labels come from omarchy-i18n, and the test only found it through an installed Omarchy. Without one, setup exited before gum and the test still passed. Put the checkout's bin on PATH and check that gum was called. Co-Authored-By: Codex gpt-6.1-sol <noreply@openai.com>
* Start sshd and open its port only once a key is authorized The setup command enabled sshd and opened port 22 before asking for a key, so a cancelled prompt, a rejected key or a GitHub user with no keys left a reachable server accepting passwords. It now installs openssh and generates host keys, authorizes the key, writes and verifies the hardening drop-in, and only then enables sshd and opens the firewall. Host keys are generated up front because sshd -t refuses to validate without them, and on a fresh machine they would otherwise first appear when the server starts. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fail the sshd test when host keys come after validation sshd -t and sshd -T exit without host keys, so on a fresh install setup only works if ssh-keygen -A runs first. The test only checked that ssh-keygen ran at all. The sshd stub now refuses to run until it has. Co-authored-by: Donald Dunsmore <215750096+thebytorsnowdog@users.noreply.github.com> * Make the cancelled sshd test prove it reached the prompt On quattro the prompt labels come from omarchy-i18n, and the test only found it through an installed Omarchy. Without one, setup exited before gum and the test still passed. Put the checkout's bin on PATH and check that gum was called. Co-Authored-By: Codex gpt-6.1-sol <noreply@openai.com> --------- Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com> Co-authored-by: Codex Medium <noreply@openai.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Ryan Hughes <ryan@heyoodle.com> Co-authored-by: Donald Dunsmore <215750096+thebytorsnowdog@users.noreply.github.com> (cherry picked from commit 0f2085b)
omacom#14667 reordered setup so sshd starts and ufw opens only after passwords are off, and replaced the test's reload assertions with assert_nothing_exposed. The loose-home case now uses it too, so a refused writable home is shown to start nothing and open nothing, not merely to skip a reload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quattro's omacom#14667 rewrote the sshd setup test with its own gum stub for a cancelled prompt, which conflicted with this branch's stub. The test file is taken from quattro as is, dropping this branch's pasted-key case: its gum stub supplied the 400-character limit the case tested, and it grepped for the flag the fix adds, both against AGENTS.md's test rules. The fix itself, --char-limit=0 on the public-key prompt, merges cleanly onto quattro's reordered script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
omarchy setup security sshdenabled and started sshd and opened port 22 in ufw before it asked for a key. Every way the key step can fail comes after that: cancelling thegumprompt, a pasted keyssh-keygenrejects, or--gh-keysfor a user with no public keys. Each one exited and left a reachable server accepting passwords with no key authorized, because the hardening drop-in is only written once a key exists.The command now installs openssh, authorizes the key, writes and verifies the hardening drop-in, and only then enables sshd and opens the firewall. A failure anywhere before that leaves nothing listening and nothing opened. Host keys are generated with
ssh-keygen -Aright after the install, becausesshd -tandsshd -Trefuse to run without them, and on a fresh machine they would otherwise first appear when the server starts. A server that is already running is reloaded rather than restarted (systemctl reload-or-restart), so an administrator already connected keeps their session.Machines that already ran the old command are covered by
migrations/1788124236.sh, which hardens them or disables sshd when no usable key is authorized. The password half of the issue already shipped in v4.0.2.The test's
systemctlandufwstubs now record any call made while the hardening drop-in is absent, and new cases for a rejected key and a cancelled prompt assert that nothing is started or opened. Thesshdstub refuses-tand-Tuntilssh-keygen -Ahas run, so generating host keys too late fails the test (the same check as #14781).Fixes #8363