omarchy-remove-security-sshd under sudo or pkexec checks root's authorized_keys, not yours
Gate 1 holds: issue 9572 and its fix PR 9573 were opened by shaynhornik on 2026-09-01, not by the account this repository uses, and the PR is still open and unmerged at the pinned sha d174d4a, the quattro tip as of 2026-09-18. Confirmed on this workstation: /usr/share/omarchy/bin/omarchy-remove-security-sshd is byte-identical to the pinned sha and line 8 reads AUTHORIZED_KEYS="$HOME/.ssh/authorized_keys" with no derivation of the invoking user. pkexec sets HOME to the target user's home directory and PATH to a fixed root PATH (polkit src/programs/pkexec.c lines 984 to 991), and /usr/bin/omarchy-cmd-present exists, so under pkexec the firewall step still runs. sudoers(5) says env_reset, on by default, sets HOME to the target user's home. I could not read /etc/sudoers or the four omarchy-settings drop-ins under /etc/sudoers.d, so an env_keep of HOME on this machine is not excluded, only unlikely. Gate 3 holds. Gate 2 fails in one place, and it is the record's central claim about how the bad invocation happens: the cause says the Omarchy skill tells an agent to run this command under pkexec. It does not. default/agents/skills/omarchy/SKILL.md line 53, at the pinned sha and as installed, says to use pkexec when no terminal is available and then, in the same sentence, Do not wrap commands that already manage privilege elevation themselves. This script manages its own elevation, calling sudo at lines 13, 17 and 18, so an agent following the skill runs it unwrapped. The requires-sudo=true header is metadata the omarchy CLI only reports through omarchy commands --json (bin/omarchy line 677), and the CLI itself execs the binary with no wrapper (line 1044), as does the menu entry at omarchy-menu.jsonc line 286 as installed. The defect is real, but it needs a person or an agent to type sudo or pkexec in front of a command that does not ask for it. The issue also states the second branch the record omits: when root does have an authorized_keys, the prompt offers to delete root's keys instead. Severity high does not meet the scale: sshd is disabled and the port closed in the same run, so the leftover key is reachable only if sshd is enabled again later. No credential or privilege boundary is exposed by the run itself, which is a control that failed silently, medium. Frequency drops to rare for the same reason, the menu, the CLI and the skill's own rule all produce the unwrapped invocation. The cited omarchy-apply-lock differs on disk from the pinned sha (the installed 4.0.2-1 copy lacks the EUID PATH block) but both derive the target user the same way. The sed line in the fix used a made-up pattern beginning AAAA, which is the prefix of every key's base64 body, so a reader who kept it would match nothing or, editing it wrong, every key. Not exercised: the command was not run under any wrapper, and no authorized_keys file was touched. Re-checked against 4.0.4-1 2026-09-19: Re-checked on 2026-09-19 against Omarchy 4.0.4-1 on this workstation and against the v4.0.4 tag, sha c668141. bin/omarchy-remove-security-sshd at v4.0.4 is byte-identical to the installed copy and to the previously pinned d174d4a. Line 8 still reads AUTHORIZED_KEYS="$HOME/.ssh/authorized_keys" with no derivation of the invoking user, and sudo is still called by the script itself at lines 13, 17 and 18. bin/omarchy-apply-lock still derives the target user from OMARCHY_INSTALL_USER, then SUDO_USER, then PKEXEC_UID. Its only v4.0.3 or v4.0.4 change is a fixed PATH when run as root, which does not touch that derivation. The menu entry, now at default/omarchy/omarchy-menu.jsonc line 294 because entries were added above it, still launches the command unwrapped. bin/omarchy still reads requires-sudo only as metadata and execs the binary directly. default/agents/skills/omarchy/SKILL.md line 53 still says not to wrap commands that manage their own elevation. Issue 9572 and fix PR 9573 are open and unmerged. Open PR 10717 edits the same script but only stops it continuing after a failed systemctl disable, and does not change how the keys path is resolved. Nothing in the v4.0.2 to v4.0.4 compare touches the script. Severity medium and frequency rare still fit the brief's scale. Gates 1, 2 and 3 still hold. Not exercised: the command was not run with or without a wrapper, and no authorized_keys file was touched.
Running the command under sudo or pkexec still stops sshd and closes the firewall port, so the session looks successful. The key left behind is the one piece the run was supposed to remove, and it becomes reachable again the moment sshd is re-enabled, for example by a later omarchy-setup-security-sshd. Do not treat a clean run of omarchy-remove-security-sshd as proof that one specific key is gone. Check ~/.ssh/authorized_keys directly.
Symptom
I ran omarchy-remove-security-sshd, or an agent ran it for me, to pull my SSH access. sshd stopped and the firewall port closed, but did it actually clear my authorized_keys?
Cause
bin/omarchy-remove-security-sshd resolves the keys file with no derivation of the invoking user:
AUTHORIZED_KEYS="$HOME/.ssh/authorized_keys"
The sibling privileged command omarchy-apply-lock derives the real target user first (OMARCHY_INSTALL_USER, then SUDO_USER, then a lookup on PKEXEC_UID) before it touches a path under that user's home. omarchy-remove-security-sshd does not. Under either sudo or pkexec, $HOME is /root for the whole script: sudo resets it to the target user's home under the default env_reset, and pkexec builds a fixed environment with HOME set to root's home directory. The removal prompt therefore inspects root's authorized_keys instead of the invoking user's. Root usually has none, so [[ -s $AUTHORIZED_KEYS ]] is false, the prompt is silently skipped, and the invoking user's real key is never touched. If root does have an authorized_keys, the prompt offers to delete root's keys instead. sshd is genuinely stopped and the firewall port genuinely closed in the same run, so it looks like it worked, but the key stays valid in the user's own ~/.ssh/authorized_keys and is live again the moment sshd is re-enabled.
No shipped path wraps the command. The omarchy menu launches it plain, omarchy-launch-floating-terminal-with-presentation omarchy-remove-security-sshd, in default/omarchy/omarchy-menu.jsonc. The omarchy CLI execs the binary with no wrapper. The script's omarchy:requires-sudo=true header is metadata that omarchy commands --json reports and nothing acts on. default/agents/skills/omarchy/SKILL.md tells an agent with no terminal to use pkexec for privileged work and, in the same sentence, not to wrap commands that already manage their own elevation, which this script does by calling sudo itself. The gap is reached only by prefixing the command with sudo at a terminal, or by an agent or script running it under pkexec against that instruction.
Fix
Invoke the command the way the omarchy menu does, plain and unwrapped, so $HOME stays yours. The systemctl and ufw calls inside it call sudo themselves and prompt for a password on their own:
omarchy-remove-security-sshd
Whichever way it was run, read your own file afterwards rather than trusting the prompt:
cat ~/.ssh/authorized_keys
If a key you meant to revoke is still listed, delete its line by the comment at the end of the line, which is usually user@host:
sed -i '/ user@host$/d' ~/.ssh/authorized_keys
or empty the file if you keep no other keys in it:
: > ~/.ssh/authorized_keys
Verify
cat ~/.ssh/authorized_keys no longer lists the key you meant to revoke, and systemctl is-enabled sshd reports disabled or fails.
Sources
- https://github.com/omacom/omarchy/issues/9572
- https://github.com/omacom/omarchy/blob/d174d4aa279ea7393d4fad4a80fed147866106b9/bin/omarchy-remove-security-sshd
- https://github.com/omacom/omarchy/blob/d174d4aa279ea7393d4fad4a80fed147866106b9/bin/omarchy-apply-lock
- https://github.com/omacom/omarchy/blob/d174d4aa279ea7393d4fad4a80fed147866106b9/default/agents/skills/omarchy/SKILL.md
- https://github.com/omacom/omarchy/blob/d174d4aa279ea7393d4fad4a80fed147866106b9/default/omarchy/omarchy-menu.jsonc
- https://github.com/omacom/omarchy/pull/9573
- https://github.com/omacom/omarchy/blob/c668141e9c42b13c80c9ca4ea108e11708c5e8a5/bin/omarchy-remove-security-sshd
- https://github.com/omacom/omarchy/blob/c668141e9c42b13c80c9ca4ea108e11708c5e8a5/default/agents/skills/omarchy/SKILL.md