Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/skills/systemd-sysupdate-verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ last success, the last error and the run it last recorded in
`/var/lib/bluefin-update-status/state`, so they survive reboots and updates,
and writes `/run/issue.d/40-bluefin-update.issue` (agetty, next to
`/usr/lib/issue.d/30-bluefin.issue`) and `/run/motd`. login (`MOTD_FILE` in
`login.defs`) and sshd (`UsePAM no`) only print `/etc/motd`, so
`login.defs`) and sshd (`PrintMotd`) only print `/etc/motd`, so
`tmpfiles.d/40-bluefin-motd.conf` links it to `/run/motd` unless the operator
has an `/etc/motd` of their own. It only reads local state and contacts
nothing. A failed check also stays a failed unit, `systemd-sysupdate.service`,
Expand Down
4 changes: 2 additions & 2 deletions docs/skills/usb-installer.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ printf 'd /home/%s 0700 %s %s -\nd /home/%s/.ssh 0700 %s %s -\nf+~ /home/%s/.ssh
# ssh.listen: systemd-ssh-generator takes the binary form only (v261 does
# not unbase64); services take the base64 form systemd-creds writes
printf 22 | enc ssh.listen - | base64 -d > ssh.listen.cred
# "*": no password login, but not locked like sysusers' default "!*", which
# sshd (UsePAM no) refuses even for keys
# "*": no password login; sshd takes the key either way (UsePAM yes), but
# "*" is not reported locked like sysusers' default "!*"
printf '*' | enc "passwd.hashed-password.$user" "passwd.hashed-password.$user.cred"
printf '!*' | enc passwd.hashed-password.root passwd.hashed-password.root.cred
# copy the five .cred files into /loader/credentials/ on the stick's ESP
Expand Down
6 changes: 6 additions & 0 deletions files/os/ssh/sshd_config.d/bluefin-server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ PermitRootLogin prohibit-password
PubkeyAuthentication yes
PasswordAuthentication no
KbdInteractiveAuthentication no
# Without PAM, sshd refuses a locked account ("!" password) even for a key,
# and root stays locked when Ignition or the ssh.authorized_keys.root
# credential gives it only a key. With PAM, FSDK's /etc/pam.d/sshd account
# stack decides instead; it ignores the password field. The two lines above
# keep PAM out of authentication, so this opens no password path.
UsePAM yes

# Keep standard SSH file transfer available without another server process.
Subsystem sftp internal-sftp
2 changes: 1 addition & 1 deletion files/os/tmpfiles.d/40-bluefin-motd.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# login (MOTD_FILE in login.defs) and sshd (UsePAM no) print /etc/motd only.
# login (MOTD_FILE in login.defs) and sshd (PrintMotd) print /etc/motd only.
# Point it at the runtime message bluefin-update-status writes. Without "+",
# an /etc/motd the operator wrote stays.
L /etc/motd - - - - ../run/motd
9 changes: 6 additions & 3 deletions scripts/dogfood-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -873,10 +873,11 @@ sync
echo "PROBE update-done"
UPDATE
# Appended to the probe of step 6: an SSH login through systemd-ssh-generator's
# local socket must print the banner (sshd reads /etc/motd). sshd refuses a
# locked root even for keys, so root gets the unlocked "*" first.
# local socket must print the banner (sshd reads /etc/motd). Root keeps its
# locked password, as with an Ignition- or credential-provisioned key: the
# login proves sshd (UsePAM yes) takes a key for a locked root.
cat > "${state}/ssh.sh" <<'SSH'
usermod -p '*' root
echo "PROBE ssh-root-locked=$(passwd -S root | cut -d' ' -f2)"
ssh-keygen -q -t ed25519 -N '' -f /run/dogfood-ssh
install -d -m 0700 /root/.ssh
cat /run/dogfood-ssh.pub >> /root/.ssh/authorized_keys
Expand Down Expand Up @@ -1113,6 +1114,8 @@ banner_lacks 6-updated boot 'FAILED'
banner_lacks 6-updated boot 'staged'
grep -aqF "PROBE ssh-motd=Bluefin Server ${next_ver}, automatic updates on" "${state}/6-updated.ttyS1.log" \
|| fail "6-updated: an SSH login does not show the banner: $(grep -a 'ssh' "${state}/6-updated.ttyS1.log" | tail -n 5)"
grep -aq 'PROBE ssh-root-locked=L' "${state}/6-updated.ttyS1.log" \
|| fail "6-updated: root was not locked for the SSH key login: $(grep -ao 'PROBE ssh-root-locked=.*' "${state}/6-updated.ttyS1.log")"

checked="a local server after reporting an unreachable and a foreign-signed source as failed checks on its banner"
[ "${next}" != release ] || checked="the image's own source"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_automatic_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def test_the_banners_are_the_files_agetty_login_and_sshd_read() -> None:
# agetty merges /run/issue.d with the image's /usr/lib/issue.d banner.
assert '"/run/issue.d/40-bluefin-update.issue"' in script
assert (ROOT / "files" / "os" / "issue.d" / "30-bluefin.issue").name < "40-bluefin-update.issue"
# shadow's login (MOTD_FILE /etc/motd) and sshd (UsePAM no) read only
# shadow's login (MOTD_FILE /etc/motd) and sshd (PrintMotd) read only
# /etc/motd; it links to the runtime file, never over an operator's own.
assert '"/run/motd"' in script
lines = [line.split() for line in MOTD_LINK.read_text(encoding="utf-8").splitlines() if line and not line.startswith("#")]
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/test_root_credential_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ def test_sshd_dropin_never_permits_password_authentication() -> None:
assert not re.search(r"^PasswordAuthentication\s+yes$", sshd, re.MULTILINE)


def test_sshd_accepts_keys_for_a_root_that_has_no_password() -> None:
# Root ships locked ("!unprovisioned"); Ignition and the
# ssh.authorized_keys.root credential give it a key without unlocking it.
# Without PAM, sshd refuses a locked account even for keys.
sshd = SSHD_DROPIN.read_text(encoding="utf-8")

assert re.search(r"^UsePAM\s+yes$", sshd, re.MULTILINE)
# The dogfood SSH login must prove it on a locked root, not unlock it.
dogfood = (REPO_ROOT / "scripts" / "dogfood-installer.sh").read_text(encoding="utf-8")
assert "usermod -p '*' root" not in dogfood


def test_generated_sshd_gets_per_device_host_keys() -> None:
dropin = GENERATED_SSHD_DROPIN.read_text(encoding="utf-8")

Expand Down
Loading