Skip to content

[Security] Set up SSH for keys only, and open nothing until a key is in place - #8365

Closed
chessing234 wants to merge 10 commits into
omacom:quattrofrom
chessing234:security/sshd-key-only
Closed

chessing234 wants to merge 10 commits into
omacom:quattrofrom
chessing234:security/sshd-key-only

Conversation

@chessing234

Copy link
Copy Markdown
Contributor

Fixes #8363.

Two things, both in what the command leaves behind.

Password authentication was never turned off. Nothing in the repo writes sshd_config, OpenSSH's own default is PasswordAuthentication yes, and Arch's /etc/ssh/sshd_config.d/99-archlinux.conf only sets KbdInteractiveAuthentication no / UsePAM yes / PrintMotd no. So a command that announces "key-based authentication" was starting a server that takes password logins from whatever network the machine is on. This writes an sshd_config.d drop-in that turns both off — Arch prepends Include /etc/ssh/sshd_config.d/*.conf to sshd_config in its PKGBUILD, so a drop-in is read — and omarchy-remove-security-sshd takes it away again.

The service and the firewall came first. setup_sshd and open_firewall ran before any key was authorized, so a cancelled gum prompt, a key ssh-keygen -lf rejects, or a --gh-keys user with no keys all left a reachable password-only sshd behind with nothing to log in with. The package still has to be installed first because ssh-keygen validates the key and ships with it, so the order is now: install → configure key-only → authorize → start → open the port.

I picked 50-omarchy-key-only.conf for the name: OpenSSH takes the first value it obtains, so a user's own lower-numbered drop-in still wins, and nothing in the shipped set claims PasswordAuthentication ahead of it.

Verification

New test/shell.d/sshd-setup-test.sh stubs sudo, ufw, ssh-keygen and omarchy-pkg-add and runs the real command:

ok - sshd setup turns password authentication off
ok - sshd setup turns keyboard-interactive authentication off
ok - sshd setup writes its config as an sshd_config.d drop-in
ok - sshd setup authorizes the key it was given
ok - sshd is configured key-only before it is started
ok - sshd starts and the port opens only after a key is authorized
ok - a rejected key leaves the ssh server stopped
ok - a rejected key leaves the firewall port closed

On the unfixed script the first assertion fails — no drop-in is written at all.

What I could not run here: this is an Arch/OpenSSH path and I have no Arch machine, so the drop-in is verified through the stubs and against the Arch openssh PKGBUILD (the Include line and the contents of 99-archlinux.conf), not against a live sshd -T. Worth a maintainer confirming sudo sshd -T | grep -i passwordauthentication reports no after the change.

omarchy-setup-security-sshd announces "key-based authentication" and then
starts sshd with the distribution defaults. OpenSSH's own default is
PasswordAuthentication yes, and Arch's 99-archlinux.conf drop-in only
turns KbdInteractiveAuthentication off, so the machine was left taking
password logins from whatever network it is attached to.

Write an sshd_config.d drop-in that turns both off, and remove it again
in omarchy-remove-security-sshd.

Enabling the service and opening the firewall also ran before the key
was authorized, so a cancelled prompt, an unparseable key or a GitHub
user with no keys left a reachable password-only server behind. Install
the package first (ssh-keygen validates the key), then configure,
authorize, and only then start and open the port.
Copilot AI balanced review requested due to automatic review settings August 26, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens SSH setup by requiring authorized keys before exposing sshd and disabling password-based authentication.

Changes:

  • Adds an OpenSSH key-only configuration drop-in.
  • Reorders setup to authorize keys before starting sshd/opening UFW.
  • Removes the drop-in during SSH teardown and adds shell tests.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 1 out of 3 changed files in this pull request and generated no comments.

File Description
bin/omarchy-setup-security-sshd Configures key-only authentication and delays network exposure.
bin/omarchy-remove-security-sshd Removes the managed sshd drop-in.
test/shell.d/sshd-setup-test.sh Tests configuration, ordering, and invalid-key behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

omarchybot and others added 2 commits August 26, 2026 05:33
`systemctl enable --now` does not touch an already-active unit, and sshd parses its configuration once at startup. On a machine an earlier run had already set up, the command wrote the drop-in, printed that password authentication was off, opened the port and reported success while the running daemon went on accepting passwords until the next reboot -- the exact state this branch exists to prevent, on every machine that had run the command before.

Verified on an Omarchy worker against a live sshd: after a successful run without this, `ssh -v` still gets `Authentications that can continue: publickey,password`; with it, `publickey`. Reload re-execs sshd in place rather than restarting it, so a user running this over their existing SSH session keeps it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
errexit is disabled inside a function invoked on the left of `||`, and every caller of `authorize_key` invokes it that way. So a `~/.ssh` that could not be written -- root-owned, read-only, out of space -- let `mkdir`, `chmod` and the append fail while the closing `echo` returned zero. The function reported success, and the branch's whole contract rests on that return value: the command then started sshd, opened port 22, and printed "your key is authorized" with no `authorized_keys` on disk at all.

That was survivable before this branch, because the server it left behind still took passwords. With them off it is a listening machine its owner cannot reach. Reproduced on an Omarchy worker with a root-owned `~/.ssh`: the command exited 0 and opened the port; it now stops at the failing `chmod`.

The GitHub path is covered by the same change -- `added` no longer counts a key that was never stored, so a fetch whose keys all fail to write exits through the existing zero-key check.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Codex XHigh <noreply@openai.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed, and the two things this fixes are real and correctly diagnosed. I verified the precedence claim on a disposable Omarchy worker (openssh 10.5p1-1, systemd 261.2-1) rather than taking it from the PKGBUILD: /etc/ssh/sshd_config line 2 is the Include, so it is the first thing read; the only drop-ins the stock system ships are 20-systemd-userdb.conf (which sets AuthorizedKeysCommand and nothing else) and 99-archlinux.conf (KbdInteractiveAuthentication no, UsePAM yes, PrintMotd no). Nothing below 50 claims PasswordAuthentication, so 50-omarchy-key-only.conf wins, and sudo sshd -T reports PasswordAuthentication no after the command runs. Your new test file also fails on the base script exactly as you said it does.

Two defects, both pushed to your branch. Both were found against a live sshd on the worker, not read off the diff.

enable --now does not reach a server that is already running. systemctl enable --now sshd.service is a no-op on an already-active unit, and sshd parses its configuration once at startup — so on any machine an earlier run had already set up, this wrote the drop-in, printed "Turning off SSH password authentication...", opened the port and finished with "Perfect!" while the running daemon went on taking passwords until the next reboot. Measured directly: after a successful run, ssh -v still got Authentications that can continue: publickey,password; the MainPID and ActiveEnterTimestamp were unchanged. That is everyone who had already run this command. start_sshd now reloads as well, which re-execs sshd in place and gets publickey alone — reload rather than restart, so someone running this over their existing SSH session keeps it. (6f88e78)

authorize_key could fail and still report success. errexit is disabled inside a function invoked on the left of ||, and every caller invokes it that way, so mkdir, chmod, touch and the append could all fail while the closing echo returned zero. Reproduced with a root-owned ~/.ssh: the append printed Permission denied, the command printed "Authorized key: ..." and "Perfect! The SSH server is running and your key is authorized", started sshd, opened port 22, and exited 0 — with no authorized_keys on disk at all. Those lines predate your branch, but your branch is what makes them load-bearing: before it, that end state still took passwords and the owner could get in; with passwords off it is a listening machine nobody can reach. They now return 1, and the --gh-keys path is covered by the same change since added no longer counts a key that was never stored. Two more assertions cover it. (0ffbd62)

Two things I did not change, for you or the maintainer to decide.

The drop-in is written before the key is authorized, so a cancelled run leaves it behind. Your comment's claim is true as written — nothing is listening and no port is open — but the config file stays. On a machine that already had sshd running with password logins and no key (set up outside Omarchy), cancelling the prompt leaves PasswordAuthentication no on disk, unapplied, until the next reboot silently applies it. Nothing needs the write to happen before the key: moving write_key_only_config to just above start_sshd keeps the guarantee that the daemon never listens with passwords on, and leaves a cancelled run having changed nothing.

Nothing checks that the drop-in actually took. The 50 prefix is the right call and it wins on a stock system, but a user's own lower-numbered drop-in setting PasswordAuthentication yes would beat it, and the command would open the firewall and report success anyway. A sudo sshd -T | grep -qx 'passwordauthentication no' gate before open_firewall would turn that from a silent wrong answer into a refusal.

Worth knowing: #7986 (opened two days before this) is a competing fix for the same issue, and the two are complementary rather than duplicates. It already has the reload, orders the drop-in write after the key, has the sshd -T check, and updates manual/48-security.md. This one has the better drop-in name (its omarchy-keys-only.conf sorts after 99-archlinux.conf, so it loses to any other drop-in) and is the only one of the two that teaches omarchy-remove-security-sshd to take the file away again — without that, removing SSH access leaves password authentication permanently disabled. Which lands is the maintainer's call; I have not touched #7986.

This closes #8363. It does not close #8248 — I confirmed on the worker that after this command runs sshd still binds 0.0.0.0:22 and [::]:22; nothing here sets ListenAddress.

Tests, all on a disposable worker and never locally: your test file (now 11 assertions, all passing), ./test/cli (passing), the mutation check that your file fails against the base script, and the mutation check that the new reload assertion fails when the reload is removed. Plus the live checks above against a real sshd — sshd -T, ssh -v auth-method probes before and after, a re-run for idempotence (no duplicate key, no duplicate ufw rule), and a full omarchy-remove-security-sshd run, which does undo everything: drop-in gone, service disabled and inactive, ufw rule gone, sshd -T back to PasswordAuthentication yes.

Second opinion from codex at xhigh reasoning. The authorize_key errexit hole is its find — I had not reasoned about it, and I reproduced it on the worker before fixing it. It reached the same conclusion I had on the reload and the cancelled-run residue; its independence there is not currently guaranteed, so read that as agreement rather than confirmation. I rejected two of its points: it called the ufw stub in your test dead, but that stub is what makes omarchy-cmd-missing ufw take the non-skip branch, and it read a failing ufw after the start as leaving the contract broken, when that fails closed — the listener is up but the port was never opened.

Waiting on the maintainer for the choice between this and #7986, and on you for the two open items above if you want them in this branch.

Two gaps a maintainer review found on a live worker, both now closed:

Writing the key-only drop-in still ran before a key was authorized, so
a cancelled prompt left PasswordAuthentication no on disk, unapplied,
until the machine's next reboot silently turned it on. Move the write
to after the key lands, alongside starting sshd -- both now wait on the
thing that makes them safe to do.

Nothing confirmed the drop-in actually won. Our own file is numbered to
beat the one Arch ships, but a user's own lower-numbered drop-in can
still set PasswordAuthentication yes and the command opened the
firewall and reported success anyway. Ask sshd -T what it actually
resolved to before opening the port, and refuse if it disagrees.

@itz4blitz itz4blitz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed this end to end against issue #8363. The ordering is the strong part and I want to call it out: package → key authorized (fail-closed prompts) → drop-in written → enable+reload → verify with sshd -T → only then open the firewall. Gating reachability on what the daemon actually resolved, rather than on the file having been written, is exactly right — and the test that keeps the port closed when sshd -T doesn't confirm key-only proves the gate bites.

A few things I checked and can confirm:

  • The Arch comment is accurate: 99-archlinux.conf only sets KbdInteractiveAuthentication off, so PasswordAuthentication yes from upstream defaults survives a bare install. The drop-in is the correct mechanism (sshd_config.d is Included first on Arch, so 50- beats 99-).
  • The authorize_key || return 1 additions are correct bash: errexit is suppressed inside a function invoked to the left of ||, so each step does have to refuse for itself. The unwritable-~/.ssh test covers the case that would otherwise silently "authorize" a key that never landed.
  • confirm_key_only fails closed on every path I can construct: malformed config makes sshd -T error, grep finds nothing, exit 1, port stays closed. A lower-numbered user drop-in overriding ours is also caught because the check asks the daemon, not the filesystem.
  • systemctl reload after enable --now correctly handles "sshd was already running from a previous setup" — without it the daemon would keep its pre-drop-in config until reboot. The test asserts reload happens after the config write.

Two non-blocking nits:

  1. On a machine where sshd.service failed to start (missing host keys on a fresh container, say), systemctl reload errors and set -e exits before the confirm — which is the right end state (port closed), but the user sees the raw systemctl error rather than a diagnosis. A || { echo hint; exit 1; } would save a support round-trip.
  2. confirm_key_only matches passwordauthentication no exactly. sshd -T prints lowercase on every OpenSSH I have, so this is fine today; if it ever changes, the failure mode is fail-closed (port stays shut), not open, which is the right way for it to break.

This supersedes #7986 in coverage — that one only turned password auth off, this one also fixes the "port open before any key exists" half of #8363.

@chessing234

Copy link
Copy Markdown
Contributor Author

the two ordering items are in. leaving the reload-error hint and the sshd -T case match.

omarchybot and others added 2 commits August 27, 2026 05:17
OpenSSH 10.5 prints `PasswordAuthentication no` from `sshd -T`, not the
lowercase `passwordauthentication no` the check grepped for, so the
confirmation never matched: on a stock Omarchy machine the command
authorized the key, wrote the drop-in, reloaded sshd into a correct
key-only state, and then refused with "a drop-in with a lower number
still allows password authentication" and left the firewall closed.
Verified against openssh 10.5p1-1 on an Omarchy worker, where `sshd -T`
now reports `PasswordAuthentication no` and `ssh -v` offers publickey
alone, and the command exits 0.

The test stub printed the lowercase form, which is why the suite passed
against a command that could not succeed on any machine it ships to. It
now prints what OpenSSH prints, and reverting the case-insensitive match
fails the suite on its first assertion.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The drop-in turns both PasswordAuthentication and KbdInteractiveAuthentication
off, but the confirmation only read the first, so a user's own lower-numbered
drop-in setting `KbdInteractiveAuthentication yes` passed the gate. With Arch's
`UsePAM yes` that is a password prompt on the network however
PasswordAuthentication resolved. Measured on an Omarchy worker with openssh
10.5p1-1: the command reported "Perfect!", opened port 22, and `ssh -v` offered
`publickey,keyboard-interactive`. It now refuses and leaves the port closed,
and the failure's Check hint names both keywords.

The stub's sshd -T output is parameterized so the two overrides can be
simulated. Without those assertions a confirmation that read no value at all --
`[[ -n $resolved ]]` -- passed the whole suite, which is how a check that
matched nothing shipped in the first place.

Co-Authored-By: Codex XHigh <noreply@openai.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed the two commits since my last pass. Both of the items I left open are in, and I confirmed each on a disposable Omarchy worker (openssh 10.5p1-1) rather than off the diff: the drop-in is now written after the key is authorized, so a cancelled prompt leaves nothing on disk for a later reboot to apply; and confirm_key_only is the check on what the daemon resolved to that was missing.

The new gate did not work, though, and it broke the command outright on any current machine. Two defects, both pushed.

sshd -T does not print lowercase. OpenSSH 10.5 prints the canonical keyword casing — PasswordAuthentication no — so grep -qx 'passwordauthentication no' never matched and confirm_key_only always returned false. Run on the worker against a real sshd, the command authorized the key, wrote the drop-in, reloaded sshd into a correctly key-only state, and then exited 1 with "A drop-in with a lower number still allows password authentication" and never opened port 22, while sudo sshd -T reported PasswordAuthentication no at that exact moment. On a fresh machine, where port 22 starts closed, that is omarchy setup security sshd failing every time and leaving the machine unreachable. The suite passed because the test's sudo/sshd stub printed the lowercase form — the assumption under test, not what OpenSSH prints. The match is now case-insensitive and the stub prints what 10.5 prints, so reverting -i fails the suite on its first assertion. (cfaac76)

This is the case match you decided to leave, and I want to be plain about why it looked safe: the review above says "sshd -T prints lowercase on every OpenSSH I have, so this is fine today; if it ever changes, the failure mode is fail-closed (port stays shut), not open, which is the right way for it to break." The first half is not true of the openssh Omarchy ships, and the second half is why it was worth catching — fail-closed here means the feature never works at all, on every machine, not that it degrades gracefully.

The gate confirmed one of the two keywords the drop-in writes. It read PasswordAuthentication and not KbdInteractiveAuthentication, so a user's own lower-numbered drop-in setting KbdInteractiveAuthentication yes passed it — and with Arch's UsePAM yes that is a password prompt on the network however PasswordAuthentication resolved. Measured: with 10-user-kbd.conf in place the command reported "Perfect!", opened port 22, and ssh -v came back Authentications that can continue: publickey,keyboard-interactive. It now refuses and leaves the port closed, and the Check hint names both keywords. The stub's sshd -T output is parameterized so both overrides are asserted; without those two assertions a confirmation reading no value at all ([[ -n $resolved ]]) passed the entire suite, which is the hole the casing bug came through. (940a695)

Three things I did not change.

A Match block still slips past the gate. sshd -T without -C dumps the global config and ignores Match stanzas — I planted Match Address 192.168.0.0/16 / PasswordAuthentication yes and sshd -T exited 0 reporting the global value. Closing it means guessing at connection parameters to pass -C, which is a design call rather than a fix.

When the gate refuses, sshd has already been started. It has to be: sshd -T exits 1 with "sshd: no hostkeys available -- exiting." when /etc/ssh has no host keys, which is the state of a machine where sshd has never run, so the check cannot move above start_sshd. The end state is safe on stock Omarchy because ufw is default-deny and the port was never opened, but on a machine with no ufw, or ufw inactive, a daemon that resolved to password logins is left running — and the failure message's claim that "the firewall port was left closed" is not quite what happened in that case.

$HOME under sudo. AUTHORIZED_KEYS="$HOME/.ssh/authorized_keys" predates this branch, but the command is marked requires-sudo=true, and sudo printenv HOME is /root on Omarchy. So sudo omarchy-setup-security-sshd --key=... authorizes the key for root — reachable, since PermitRootLogin is prohibit-password — and leaves the invoking user with no key and, now, no password fallback. Resolving it through SUDO_USER is a behaviour change I have left for the maintainer.

Two test gaps worth knowing about, neither of which changes behaviour: key_line is the ssh-keygen validation call rather than the authorized_keys append, so the ordering assertion proves the drop-in comes after validation rather than after the key is stored; and the invalid-key and unwritable-~/.ssh blocks assert that nothing starts and nothing opens, but never that no drop-in was written, which is the property that fd7ec41 actually added.

Worth knowing for whoever picks between this and #7986: that one carries the identical casing bug — grep -qx 'passwordauthentication no' against a stub that prints lowercase — so it would fail the same way on 10.5. It independently documents the host-key reason the check cannot precede the start, which matches what I measured. It also updates manual/48-security.md, which this branch does not; the manual still describes the setup as opening port 22 without mentioning that password logins are now off.

Tests, all on a disposable worker and never locally: this file (now 15 assertions, passing), ./test/cli (116 assertions, passing), and mutation checks that reverting -i, dropping the keyboard-interactive line, or replacing the predicate with one that reads no value each fail the suite. Live against a real sshd: sshd -T before and after, ssh -v auth-method probes, the lower-numbered PasswordAuthentication yes and KbdInteractiveAuthentication yes overrides both refused with the port closed, the happy path exiting 0 with publickey alone, and two consecutive runs producing no duplicate key and no duplicate ufw rule.

Second opinion from codex at xhigh reasoning. The keyboard-interactive hole is its find — I had not reasoned about it, and I reproduced it on the worker before fixing it. The mutation gap in the stub and the key_line observation are also its, verified before I acted. It agreed with the casing analysis I had already reached, and its independence is not currently guaranteed, so read that as agreement rather than confirmation. I rejected one of its style points: it faulted the added comments for length against a rule that is not in this repo's AGENTS.md.

Waiting on the maintainer for the choice against #7986, the Match block question, and the sudo $HOME behaviour.

quattro now disables password auth after authorize, but still opens the
firewall before a key exists. Keep the package → key → drop-in → start →
confirm → firewall order from this branch, and clean the legacy
10-omarchy-hardening.conf on remove.
@chessing234

Copy link
Copy Markdown
Contributor Author

rebased onto quattro; kept the key-before-firewall order. also cleans the legacy 10-omarchy-hardening.conf on remove.

@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at e6c2b0a1. The only new thing since the last pass is the merge of quattro, and that merge is where the problem is: upstream landed its own sshd hardening in the meantime and shipped it in v4.0.2.

What is still yours, and worth keeping. Upstream's disable_password_auth now writes the same two directives and verifies them against sshd -T, so the "password authentication was never turned off" half of #8363 is already fixed on quattro. The other half is not — bin/omarchy-setup-security-sshd:192-193 on quattro still runs setup_sshd and open_firewall before any key is authorized. Key-before-listen is entirely yours and nobody else has done it.

But the merge resolved bin/omarchy-setup-security-sshd in favour of this branch's rewrite, and that drops three things upstream shipped.

1. A remote lockout, through the drop-in filename. bin/omarchy-setup-security-sshd:11 writes 50-omarchy-key-only.conf. The migration shipped in v4.0.2 uses 10-omarchy-hardening.conf (migrations/1788124236.sh:3) and treats its presence as the machine-wide completion marker (migrations/1788124236.sh:25), because omarchy-migrate keeps migration state per user under $HOME/.local/state/omarchy/migrations. Rename the file and that marker never appears: a second account on the machine runs the migration, finds no 10-…, finds sshd enabled, finds no authorized_keys of its own, and reaches migrations/1788124236.sh:69 — systemctl disable --now sshd.service. The machine you just set up key-only stops answering SSH, and the account that holds the working key had nothing to do with it. Reproduced on a worker against this merged tree: with a valid key authorized and 50-omarchy-key-only.conf in place, the migration logs sudo systemctl disable --now sshd.service.

2. 50- is weaker than 10- on its own terms. sshd takes the first value it obtains and Include /etc/ssh/sshd_config.d/*.conf expands in sort order, so an administrator's 20-anything.conf carrying PasswordAuthentication yes loses to upstream's 10- and wins against 50-. The reasoning in the PR body is right about the shipped set, where nothing claims PasswordAuthentication ahead of it; it is hand-written and third-party drop-ins that 10- was chosen to beat. confirm_key_only does catch that case and holds the firewall closed, but only after start_sshd has already enabled and started the daemon, so the failure path leaves a password-taking sshd enabled at boot.

3. sshd -t and the rollback are gone. Upstream validates before reloading and removes its own drop-in when either sshd -t or sshd -T says no, precisely so a config sshd rejects cannot take the service down on its next restart. This branch has no sshd -t at all, and neither a failed reload nor a failed confirm_key_only removes 50-omarchy-key-only.conf — it stays staged for the next boot.

Also in bin/omarchy-remove-security-sshd. Line 14 swallows every failure of systemctl disable --now, and lines 16-25 then delete both hardening files unconditionally, so if systemd refuses while sudo still works you have removed the password protection from a daemon that is still enabled and running. Upstream's remove left the hardening file alone. Separately, sudo test -f does not see a dangling symlink, which the migration deliberately does treat as present (-e || -L).

Tests, all on a disposable worker VM, never on the machine doing the review. test/shell.d/sshd-setup-test.sh (yours): 15 passed. test/shell.d/sshd-hardening-migration-test.sh (upstream's): 15 passed. test/shell.d/setup-security-sshd-test.sh — upstream's, added in v4.0.2, not touched by this branch — fails: 0 passed, exit 1, tee: /etc/ssh/sshd_config.d/50-omarchy-key-only.conf: Permission denied. test/shell globs *-test.sh, so both files run and CI will be red. That same file passes 4/4 on the merge base, so this branch is what breaks it. The immediate cause is that upstream's sudo stub handles sudo install and falls through to exec "$@" for sudo tee, so the suite reaches for the machine's real /etc/ssh/sshd_config.d — worth knowing on its own, because a suite run as root would have written there. Past that, its assertions at lines 84, 92, 100-103 and 108-116 contradict this implementation directly.

A shape that would fix all of it. Every point above disappears if the branch stops reimplementing the hardening step and keeps only what upstream does not have: leave upstream's disable_password_auth exactly as it is, and change the call order at the bottom of the script so the key is authorized first and open_firewall runs last. That is roughly a ten-line diff. It keeps the 10- filename the migration depends on, it keeps sshd -t and the rollback, and upstream's test file goes on passing. Reducing the change that far is your call and the maintainer's rather than something to push onto your branch, so nothing was pushed here.

Reviewed by Claude Opus 5 in Claude Code, with an independent second opinion from Codex at xhigh reasoning pinned to e6c2b0a1. Codex agreed on the filename regression, the missing sshd -t, the cross-account lockout and the test conflict — its independence is not currently guaranteed, so read that as agreement rather than confirmation. Three things it contributed that this review had not reasoned about: the 20-*.conf precedence argument in point 2, the omarchy-remove-security-sshd failure path, and the dangling-symlink gap.

Waiting on you for the reshape, and on the maintainer for whether to take the reduced version or close this in favour of what upstream already shipped.

The previous branch reimplemented the drop-in and raced the v4.0.2
hardening. Leave disable_password_auth alone and only change call order
so a cancelled prompt cannot enable sshd or open port 22.
@chessing234

Copy link
Copy Markdown
Contributor Author

folded into #12099 — same sshd setup script, one review is enough.

chessing234 added a commit to chessing234/omarchy that referenced this pull request Sep 25, 2026
Fold key-before-listen ordering from omacom#8365 onto the localhost bind from omacom#11513 so a rejected key never enables sshd.
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.

[Security] omarchy setup security sshd leaves password authentication on, and opens the port before any key is authorized

4 participants