Repository navigation
Keep SSH setup from disabling passwords on a writable home - #9506
mark-groves wants to merge 4 commits into
Conversation
The companion migration already refuses to harden when StrictModes would ignore authorized_keys. The interactive setup command did not, so it could write PasswordAuthentication no and report key-only access on a group- or world-writable home.
|
Reviewed at The bug, reproduced with a real sshd. A throwaway user with a key in This branch on the same machine. With a 775 home it exits 1 with the writable-home message. It writes no drop-in, and sshd still offers Tests on the worker: The check matches what Second opinion: none. The reviewer, Codex Medium, was reachable, but today's review budget was already spent. So this is one model's review, by Claude Opus 5.5. Related: #9463, a draft that conflicts with This now waits on a second-opinion review and then on the maintainer. |
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>
sshd resolves the home directory before checking its modes under StrictModes, so a home that is a symlink to a 755 directory accepts keys. stat without -L read the link's own 777 and refused to harden it, with a message telling the user their home was writable when it was not. With -L the guard checks what sshd checks, and still refuses a symlink to a writable directory. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The homes were made by mkdir -p under the ambient umask, so under umask 002 every case's home was 775 and the new writable-home guard failed them all. run_setup now sets 755 unless a case asks for another mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The PR appears safe to merge; the previous test-permission issue is fixed. SummarySSH setup refuses to disable passwords when the home directory is writable by others or its permissions cannot be read.
Reviews (2) · Last reviewed commit: "Give the sshd test homes an explicit mod..." · Reviewed by Greptile |
|
This branch had stopped merging after #14667 reordered SSH setup on The merge ( Symlinked home ( Test umask ( Verified on a disposable Omarchy worker with a real sshd (OpenSSH 10.6p2). I used a throwaway user with a 775 home and set it up with
Second opinion. Codex Medium and muse-wonder (via pi, thinking high) reviewed it in three rounds, each on the head it was asked about, and the last round found nothing open. Codex proposed the Still open, for the maintainer: like the migration, the guard checks only that This waits on the maintainer. |
Why
OpenSSH StrictModes is on by default. When
$HOMEis group-writable or world-writable, sshd ignoresauthorized_keys.omarchy-setup-security-sshdalready runschmod 700on~/.sshandchmod 600on the keys file. It then writesPasswordAuthentication noto/etc/ssh/sshd_config.d/10-omarchy-hardening.confand prints that password logins are off. If$HOMEis mode775or777, that write closes the only login sshd still accepted. New SSH sessions get neither a key nor a password.migrations/1788124236.shalready refuses to harden in that case. The skip text tells you to runomarchy-setup-security-sshd. That command still writes the drop-in.The patch adds the same home-mode check to
disable_password_auth.Scope
bin/omarchy-setup-security-sshd,disable_password_authonly.After the empty-key return, the function stats
$HOME. Ifstatfails, the function returns 1. If the mode has group-write or other-write (8#022), the function returns 1. It does not write10-omarchy-hardening.confand does not reload sshd.test/shell.d/setup-security-sshd-test.shadds aHOME_MODEhook onrun_setupand a775case namedloose-home. That case must fail the command, leave the drop-in unwritten, skipsystemctl reload sshd.service, and print the writable-home error.This PR does not chmod
$HOME. It does not check ownership or ACLs. It does not include the rewrite in #9463 that proves key-only access before it starts sshd.Tradeoffs
If the function returns 1, sshd stays enabled and port 22 stays open. Password logins stay on. The authorized key stays in place and StrictModes still ignores it. That is the machine's prior state. A chmod of
$HOMEwould make the key work, but the home directory is not this command's to change. The migration made the same call.A
700or755home still hardens. Those are the modes ArchHOME_MODEand a typical umask create.Blast Radius
The check runs for every
omarchy-setup-security-sshdinvocation, including the Setup menu and the--keyor--gh-keysflags.On a default Omarchy install
$HOMEis700. Mode755is also safe. The new return fires only when$HOMEhas group-write or world-write. A user at the desktop still has local login. The unattended flags are the case where a false "passwords are off" line matters more.The predicate matches the migration. A
775home that the migration already skips now gets the same refusal from the command the skip text names.Verification
Ran
./test/shell.d/setup-security-sshd-test.shonaf887538. All five cases passed, includingSSH setup leaves passwords on when the home directory is group-writable.