From c97cc57ae265f26e5c122a460f510d95788d3070 Mon Sep 17 00:00:00 2001 From: Jeffrey Sica Date: Mon, 28 Sep 2026 22:00:13 -0500 Subject: [PATCH 1/4] fix(security): ship root locked; firstboot applies passwd credentials The /usr image baked a SHA-512 hash of the public password "bluefin" into the factory /etc/shadow and the console banner advertised it, so anyone with console, IPMI or serial access to any node, or a copy of the public DDI, knew root's password. Seed root as "!unprovisioned" instead: login, su and sulogin treat it as locked, and systemd-firstboot treats it as "root not configured", so a passwd.hashed-password.root / passwd.plaintext-password.root credential still sets it (systemd-sysusers cannot: it only sets passwords for accounts it creates). Drop upstream's --prompt-root-password from systemd-firstboot.service so a node without the credential, and the USB installer's console, boot unattended instead of waiting on a prompt. Replace the banner's default-login line with a pointer to the node access docs, and pin the contract in tests: root ships !unprovisioned, no crypt(5) hash appears under elements/, files/ or include/, firstboot never prompts for a root password, and the banner advertises no credentials. Assisted-by: Claude Opus 5.5 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- elements/bluefin-server/os-creds-prov.bst | 4 + elements/oci/bluefin-server-usr.bst | 9 +- .../10-bluefin-no-root-prompt.conf | 9 + files/os/issue.d/30-bluefin.issue | 2 +- .../os/ssh/sshd_config.d/bluefin-server.conf | 10 +- files/os/sysusers.d/10-root-creds.conf | 4 +- tests/unit/test_root_credential_contract.py | 154 +++++++++++++----- 7 files changed, 140 insertions(+), 52 deletions(-) create mode 100644 files/os/creds/systemd/system/systemd-firstboot.service.d/10-bluefin-no-root-prompt.conf diff --git a/elements/bluefin-server/os-creds-prov.bst b/elements/bluefin-server/os-creds-prov.bst index 2ecea907..dc9de124 100644 --- a/elements/bluefin-server/os-creds-prov.bst +++ b/elements/bluefin-server/os-creds-prov.bst @@ -5,6 +5,10 @@ description: | Supports sysusers credentials, systemd-network-generator network.* credentials, and the firstboot.* credentials (locale, keymap, timezone, hostname). + The systemd-firstboot.service drop-in removes upstream's interactive root + password prompt: root ships locked, so without it every headless boot would + wait on the console. The passwd.*.root credentials still apply. + Flatcar's /usr is built without systemd-firstboot, so the firstboot.* credentials are applied by /usr/libexec/bluefin-firstboot-credentials, a bash + coreutils helper that writes the same files systemd-firstboot would diff --git a/elements/oci/bluefin-server-usr.bst b/elements/oci/bluefin-server-usr.bst index 5ccab92e..3663c839 100644 --- a/elements/oci/bluefin-server-usr.bst +++ b/elements/oci/bluefin-server-usr.bst @@ -56,10 +56,13 @@ config: set -eu systemd-sysusers --root=/sysroot chmod 0600 /sysroot/etc/shadow /sysroot/etc/gshadow - # Console bring-up password: root/bluefin, expired so the first login - # forces a rotation. sshd refuses passwords (os-sshd-config.bst). + # No shipped password: root is locked. "!unprovisioned" is systemd's + # marker for a root account nobody has configured yet; login, su and + # sulogin treat it as locked, and systemd-firstboot still applies a + # passwd.hashed-password.root / passwd.plaintext-password.root + # credential over it (docs/skills/tpm2-credential-sealing.md). sed -i '/^root:/d' /sysroot/etc/shadow - printf 'root:%s:0:0:99999:7:::\n' '$6$bluefin123$o2pQjPN1n3ZCnYUROlA01xAdnGO7mhVRAVw98x4xc8LAUIJv7b44bBNoER6fM4P.rrj4ePYFfkx9WvZICU8nt/' >> /sysroot/etc/shadow + printf 'root:!unprovisioned:::::::\n' >> /sysroot/etc/shadow grep -q '^root:' /sysroot/etc/passwd chmod 0400 /sysroot/etc/shadow /sysroot/etc/gshadow diff --git a/files/os/creds/systemd/system/systemd-firstboot.service.d/10-bluefin-no-root-prompt.conf b/files/os/creds/systemd/system/systemd-firstboot.service.d/10-bluefin-no-root-prompt.conf new file mode 100644 index 00000000..70f24aae --- /dev/null +++ b/files/os/creds/systemd/system/systemd-firstboot.service.d/10-bluefin-no-root-prompt.conf @@ -0,0 +1,9 @@ +# Root ships locked as "!unprovisioned" (bluefin-server-usr.bst), which +# systemd-firstboot reads as "root not configured yet". Upstream's +# --prompt-root-password would then block every headless boot, and the USB +# installer's console, on a password prompt. Drop only that prompt: the +# passwd.hashed-password.root / passwd.plaintext-password.root credentials +# still apply, and without one root stays locked. +[Service] +ExecStart= +ExecStart=systemd-firstboot --prompt-locale --prompt-keymap-auto --prompt-timezone --mute-console=yes diff --git a/files/os/issue.d/30-bluefin.issue b/files/os/issue.d/30-bluefin.issue index 2ac9d6c1..cfd34f0a 100644 --- a/files/os/issue.d/30-bluefin.issue +++ b/files/os/issue.d/30-bluefin.issue @@ -1,3 +1,3 @@ Bluefin Server (\l) -Default login: root / bluefin (password change forced at first login) +No default login; root is locked. Provision access: https://github.com/projectbluefin/server/blob/main/docs/skills/tpm2-credential-sealing.md#node-access diff --git a/files/os/ssh/sshd_config.d/bluefin-server.conf b/files/os/ssh/sshd_config.d/bluefin-server.conf index 4994e4a9..1d78bada 100644 --- a/files/os/ssh/sshd_config.d/bluefin-server.conf +++ b/files/os/ssh/sshd_config.d/bluefin-server.conf @@ -1,9 +1,9 @@ # SSH configuration for Bluefin Server. -# Hardened defaults: no direct root password login, no password auth at all. -# Bring-up diagnostics stay available on the local console (root / bluefin, -# see the issue banner); for remote access inject an authorized_keys entry -# via the installer or systemd credentials. The seeded default password must -# never be usable over the network. +# Hardened defaults: key-only, no password auth at all. Root ships locked; +# provision an authorized key per node through Ignition or the +# ssh.authorized_keys.root credential (docs/skills/tpm2-credential-sealing.md). +# A console password set through a credential must never be usable over the +# network. PermitRootLogin prohibit-password PubkeyAuthentication yes diff --git a/files/os/sysusers.d/10-root-creds.conf b/files/os/sysusers.d/10-root-creds.conf index 5198d84f..705b8ed8 100644 --- a/files/os/sysusers.d/10-root-creds.conf +++ b/files/os/sysusers.d/10-root-creds.conf @@ -1,2 +1,4 @@ -# Read root user hashed password from systemd credential storage +# root's account entry. Its password is not set here: the image ships root +# locked ("!unprovisioned", bluefin-server-usr.bst) and systemd-firstboot +# applies the passwd.*.root credentials (docs/skills/tpm2-credential-sealing.md). u root 0 "root" /root /bin/bash diff --git a/tests/unit/test_root_credential_contract.py b/tests/unit/test_root_credential_contract.py index 7d2fbf99..d933d947 100644 --- a/tests/unit/test_root_credential_contract.py +++ b/tests/unit/test_root_credential_contract.py @@ -1,13 +1,16 @@ -"""Contracts for the seeded root credential and SSH login policy. - -The shipped DDI seeds a well-known default root password for local console -bring-up only. This file pins the two safety contracts around it: - -- the password is expired at first login (shadow last-change field 0, the - `chage -d 0` equivalent), so every install is forced onto a per-install - secret before any shell is granted; and -- the effective SSH policy never allows the seeded password (or any password) - over the network. +"""Contracts for root's shipped credential and the SSH login policy. + +The public DDI must not carry a usable password: root ships locked as +``!unprovisioned`` and access is provisioned per node (Ignition, or the +``passwd.*.root`` / ``ssh.authorized_keys.root`` system credentials). This +file pins that contract: + +- the /usr image seeds root as ``!unprovisioned``, the only locked value + systemd-firstboot still provisions from a password credential; +- no crypt(5) hash is baked into any element or image payload file; +- systemd-firstboot cannot block a headless boot on a root password prompt; +- the console banner advertises no credentials; and +- the effective SSH policy never allows a password over the network. """ from __future__ import annotations @@ -16,43 +19,97 @@ from pathlib import Path REPO_ROOT = Path(__file__).resolve().parents[2] -DDI_ELEMENT = REPO_ROOT / "elements" / "oci" / "bluefin-server-usr.bst" +USR_ELEMENT = REPO_ROOT / "elements" / "oci" / "bluefin-server-usr.bst" +CREDS_ELEMENT = REPO_ROOT / "elements" / "bluefin-server" / "os-creds-prov.bst" +FIRSTBOOT_DROPIN = ( + REPO_ROOT + / "files" + / "os" + / "creds" + / "systemd" + / "system" + / "systemd-firstboot.service.d" + / "10-bluefin-no-root-prompt.conf" +) SSHD_DROPIN = REPO_ROOT / "files" / "os" / "ssh" / "sshd_config.d" / "bluefin-server.conf" ISSUE_FILE = REPO_ROOT / "files" / "os" / "issue.d" / "30-bluefin.issue" -KUBESTELLAR_ISSUE = REPO_ROOT / "files" / "kubestellar" / "sysext" / "40-kubestellar.issue" - - -def _root_shadow_fields(ddi_element: str) -> list[str]: - match = re.search( - r"printf '(root:%s:[^']*)' '([^']*)'", ddi_element - ) - assert match, "/usr image element must seed a root account into /etc/shadow" - shadow_line = match.group(1).split("\\n")[0].replace("%s", match.group(2)) - fields = shadow_line.split(":") - assert fields[0] == "root", "seeded shadow line must be the root account" - assert len(fields) == 9, "seeded shadow line must have all 9 shadow fields" - return fields +ACCESS_SKILL = REPO_ROOT / "docs" / "skills" / "tpm2-credential-sealing.md" +# crypt(5) hash strings: MD5, bcrypt, SHA-256/512, scrypt, yescrypt, +# gost-yescrypt and sunmd5 prefixes followed by a salt/parameter field. +CRYPT_HASH_RE = re.compile(r"\$(?:1|2[abxy]|5|6|7|y|gy|md5)\$[./0-9A-Za-z,=]+\$") +# Signing material is gitignored and generated per checkout; it is not image +# payload text. +SCANNED_TREES = ("elements", "files", "include") +SKIPPED_TREES = ("files/boot-keys",) -def test_root_password_is_expired_for_first_login_rotation() -> None: - ddi_element = DDI_ELEMENT.read_text(encoding="utf-8") - fields = _root_shadow_fields(ddi_element) - # shadow field 2 is the last-change date: 0 means expired, so login - # (console included) forces a password rotation before any shell. - assert fields[2] == "0", ( - "seeded root password must be expired at first login (last-change 0); " - "a fixed date leaves the well-known default usable indefinitely" - ) +def _seeded_root_shadow_line(element: str) -> str: + match = re.search(r"printf '(root:[^']*)'", element) + assert match, "/usr image element must seed root's /etc/shadow entry" + return match.group(1).split("\\n")[0] -def test_root_password_uses_no_fixed_build_date() -> None: - ddi_element = DDI_ELEMENT.read_text(encoding="utf-8") - fields = _root_shadow_fields(ddi_element) +def test_root_ships_unprovisioned_and_locked() -> None: + fields = _seeded_root_shadow_line(USR_ELEMENT.read_text(encoding="utf-8")).split(":") - # Regression guard: a fixed last-change date (e.g. 19700) ships the same - # usable credential in every image with no rotation enforced. - assert fields[2] != "19700" + assert len(fields) == 9, "seeded shadow line must have all 9 shadow fields" + assert fields[0] == "root" + # "!unprovisioned" is locked for login/su/sulogin (leading "!") and is the + # value systemd-firstboot treats as "root not configured", so a + # passwd.hashed-password.root credential can still set it. "!*" or "*" + # would lock root with no credential path at all. + assert fields[1] == "!unprovisioned" + + +def test_no_password_hash_is_baked_into_the_image() -> None: + offenders = [] + for tree in SCANNED_TREES: + for path in sorted((REPO_ROOT / tree).rglob("*")): + rel = path.relative_to(REPO_ROOT).as_posix() + if not path.is_file() or rel.startswith(SKIPPED_TREES): + continue + try: + text = path.read_text(encoding="utf-8") + except UnicodeDecodeError: + continue + if CRYPT_HASH_RE.search(text): + offenders.append(rel) + + assert not offenders, f"crypt(5) password hashes baked into image sources: {offenders}" + + +def test_crypt_hash_pattern_catches_known_formats() -> None: + for sample in ( + "$6$saltsalt$Mbb3dJ5M1XbRhW0XgW7hJvB0kxc", + "$y$j9T$F5Jx5fExrKuPp53xLKQ..1$X3DX6M94c7o.9agCG9G317fhZg9SqC.5i5rd.RhAtQ7", + "$5$rounds=5000$salt$hash", + "$2b$12$abcdefghijklmnopqrstuu", + ): + assert CRYPT_HASH_RE.search(sample), sample + assert not CRYPT_HASH_RE.search('printf "%s" "$6"') + + +def test_firstboot_never_prompts_for_a_root_password() -> None: + dropin = FIRSTBOOT_DROPIN.read_text(encoding="utf-8") + exec_lines = re.findall(r"^ExecStart=(.*)$", dropin, re.MULTILINE) + + # An empty ExecStart= resets upstream's command, which carries + # --prompt-root-password and would wait on the console of every + # headless boot (and the USB installer) now that root is unprovisioned. + assert exec_lines[0] == "" + assert len(exec_lines) == 2 + assert exec_lines[1].startswith("systemd-firstboot ") + assert "--prompt-root-password" not in exec_lines[1] + assert "--prompt-root-shell" not in exec_lines[1] + assert "--prompt " not in f"{exec_lines[1]} " + + +def test_firstboot_dropin_is_installed() -> None: + element = CREDS_ELEMENT.read_text(encoding="utf-8") + + assert "path: files/os/creds/systemd/system" in element + assert 'cp -a systemd-src/. "%{install-root}/usr/lib/systemd/system/"' in element def test_sshd_dropin_never_permits_password_authentication() -> None: @@ -65,8 +122,21 @@ def test_sshd_dropin_never_permits_password_authentication() -> None: assert not re.search(r"^PasswordAuthentication\s+yes$", sshd, re.MULTILINE) -def test_console_banner_discloses_forced_password_change() -> None: +def test_console_banner_advertises_no_credentials() -> None: + banner = ISSUE_FILE.read_text(encoding="utf-8") + + assert not re.search(r"password", banner, re.IGNORECASE) + assert not re.search(r"\blogin\s*:", banner, re.IGNORECASE) + assert "bluefin123" not in banner + assert not re.search(r"root\s*/\s*\S", banner) + assert "root is locked" in banner + + +def test_console_banner_points_at_the_access_skill() -> None: banner = ISSUE_FILE.read_text(encoding="utf-8") + match = re.search(r"https://github\.com/projectbluefin/server/blob/main/(\S+?)#(\S+)", banner) - assert "Default login: root / bluefin" in banner - assert "password change forced at first login" in banner + assert match, "banner must link the canonical node access docs" + target = REPO_ROOT / match.group(1) + assert target == ACCESS_SKILL + assert f"## {match.group(2).replace('-', ' ').capitalize()}" in target.read_text(encoding="utf-8") From fcd1534fec1fb26fd19285752a9218893783569a Mon Sep 17 00:00:00 2001 From: Jeffrey Sica Date: Mon, 28 Sep 2026 22:35:27 -0500 Subject: [PATCH 2/4] fix(ssh): give systemd-ssh-generator's sshd per-device host keys systemd-ssh-generator socket-activates a per-connection sshd for the ssh.listen credential, AF_VSOCK and the local AF_UNIX socket. It ran without host keys, which ssh-host-keygen.service only generates before sshd.service, so every connection ended in "no hostkeys available". Pull the same one-shot key generation in before it, which makes ssh.listen a working credential-only way to open SSH on a node whose root is locked. Assisted-by: Claude Opus 5.5 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- elements/bluefin-server/os-k0s-first-boot.bst | 3 ++- .../10-host-keygen.conf | 7 +++++++ tests/unit/test_root_credential_contract.py | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 files/os/systemd/system/sshd-generated@.service.d/10-host-keygen.conf diff --git a/elements/bluefin-server/os-k0s-first-boot.bst b/elements/bluefin-server/os-k0s-first-boot.bst index 66985341..e45d742a 100644 --- a/elements/bluefin-server/os-k0s-first-boot.bst +++ b/elements/bluefin-server/os-k0s-first-boot.bst @@ -2,7 +2,8 @@ kind: import description: | Install the systemd units from files/os/systemd/system: the first-boot k0s sysext activation units, first-start SSH host key generation - (ssh-host-keygen.service plus its sshd.service drop-in), the installer + (ssh-host-keygen.service plus its sshd.service and systemd-ssh-generator + sshd-generated@.service drop-ins), the installer source ESP mounts (run-bluefin-boot.mount for netboot, run-bluefin-installer.mount for the USB installer), and the systemd-sysinstall.service drop-in the USB installer boots into. diff --git a/files/os/systemd/system/sshd-generated@.service.d/10-host-keygen.conf b/files/os/systemd/system/sshd-generated@.service.d/10-host-keygen.conf new file mode 100644 index 00000000..d7a478b3 --- /dev/null +++ b/files/os/systemd/system/sshd-generated@.service.d/10-host-keygen.conf @@ -0,0 +1,7 @@ +# systemd-ssh-generator's per-connection sshd (behind the ssh.listen +# credential, AF_VSOCK and the local AF_UNIX socket) needs the same +# per-device host keys as sshd.service; without them it exits with +# "no hostkeys available". See ssh-host-keygen.service. +[Unit] +Wants=ssh-host-keygen.service +After=ssh-host-keygen.service diff --git a/tests/unit/test_root_credential_contract.py b/tests/unit/test_root_credential_contract.py index d933d947..6cd45c1d 100644 --- a/tests/unit/test_root_credential_contract.py +++ b/tests/unit/test_root_credential_contract.py @@ -32,6 +32,15 @@ / "10-bluefin-no-root-prompt.conf" ) SSHD_DROPIN = REPO_ROOT / "files" / "os" / "ssh" / "sshd_config.d" / "bluefin-server.conf" +GENERATED_SSHD_DROPIN = ( + REPO_ROOT + / "files" + / "os" + / "systemd" + / "system" + / "sshd-generated@.service.d" + / "10-host-keygen.conf" +) ISSUE_FILE = REPO_ROOT / "files" / "os" / "issue.d" / "30-bluefin.issue" ACCESS_SKILL = REPO_ROOT / "docs" / "skills" / "tpm2-credential-sealing.md" @@ -122,6 +131,15 @@ def test_sshd_dropin_never_permits_password_authentication() -> None: assert not re.search(r"^PasswordAuthentication\s+yes$", sshd, re.MULTILINE) +def test_generated_sshd_gets_per_device_host_keys() -> None: + dropin = GENERATED_SSHD_DROPIN.read_text(encoding="utf-8") + + # The ssh.listen credential is the credential-only way to open SSH; its + # systemd-ssh-generator sshd exits without host keys. + assert re.search(r"^Wants=ssh-host-keygen\.service$", dropin, re.MULTILINE) + assert re.search(r"^After=ssh-host-keygen\.service$", dropin, re.MULTILINE) + + def test_console_banner_advertises_no_credentials() -> None: banner = ISSUE_FILE.read_text(encoding="utf-8") From 11bb8f3b8e671723dead58f369f8f47da5ae12a3 Mon Sep 17 00:00:00 2001 From: Jeffrey Sica Date: Mon, 28 Sep 2026 22:00:13 -0500 Subject: [PATCH 3/4] docs(skills): document per-node access with root locked Add a "Node access" section to the credentials skill: root ships locked, SSH keys come from Ignition or the ssh.authorized_keys.root credential, the console password from passwd.*.root credentials applied by systemd-firstboot, when that applies on diskless and installed nodes (and why it survives A/B updates), how USB-installed nodes get credentials, and what a locked root means for emergency/rescue (no SYSTEMD_SULOGIN_FORCE). Fix factory-integration.md, which still claimed root password login over SSH is permitted (#245), and route "node access" to the skill. Assisted-by: Claude Opus 5.5 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- AGENTS.md | 2 +- docs/skills/factory-integration.md | 4 +- docs/skills/index.md | 4 +- docs/skills/tpm2-credential-sealing.md | 92 ++++++++++++++++++++------ 4 files changed, 76 insertions(+), 26 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 4d24050c..9d1ac1a9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -70,7 +70,7 @@ All local `just` targets run BuildStream inside the FSDK `bst2` container via `j | Update the FSDK pin / versioning | [`docs/skills/bump-fsdk-version.md`](docs/skills/bump-fsdk-version.md) | | CI workflows, action SHA pinning | [`docs/skills/ci-tooling.md`](docs/skills/ci-tooling.md) | | Release signing / sysupdate trust | [`docs/skills/systemd-sysupdate-verification.md`](docs/skills/systemd-sysupdate-verification.md) | -| Credential sealing with TPM2 | [`docs/skills/tpm2-credential-sealing.md`](docs/skills/tpm2-credential-sealing.md) | +| Node access (root / SSH) and credential sealing with TPM2 | [`docs/skills/tpm2-credential-sealing.md`](docs/skills/tpm2-credential-sealing.md) | | System containers (`machinectl`) | [`docs/skills/system-containers.md`](docs/skills/system-containers.md) | | Cut bloat / avoid over-engineering | [`docs/skills/avoid-over-engineering.md`](docs/skills/avoid-over-engineering.md) | | Add or refactor skills | [`docs/skills/skill-improvement.md`](docs/skills/skill-improvement.md) | diff --git a/docs/skills/factory-integration.md b/docs/skills/factory-integration.md index a12e841e..8db72aa2 100644 --- a/docs/skills/factory-integration.md +++ b/docs/skills/factory-integration.md @@ -4,7 +4,7 @@ description: Understand Bluefin Server's role as the core OS for an image-based metadata: type: reference status: stable - last_updated: "2026-09-27" + last_updated: "2026-09-28" --- # Factory Integration @@ -65,7 +65,7 @@ the base /usr image (hard rule 4 forbids container runtimes in the base image). ## SSH and Remote Diagnostics -> `sshd` is present in the OS image for on-demand diagnostics and bring-up troubleshooting, but is disabled by default via `disable sshd.service` in systemd presets. Operators can start it on-demand with `systemctl start sshd` or enable it when remote access is required. Root login is permitted with password and pubkey. +> `sshd` is present in the OS image for on-demand diagnostics and bring-up troubleshooting, but is disabled by default via `disable sshd.service` in systemd presets. Operators can start it on-demand with `systemctl start sshd` or enable it when remote access is required. Login is key-only (`PermitRootLogin prohibit-password`, `PasswordAuthentication no`), and root ships locked; provision keys per node as described under "Node access" in [tpm2-credential-sealing.md](tpm2-credential-sealing.md). ## When to Use diff --git a/docs/skills/index.md b/docs/skills/index.md index 084d53d3..deaeab98 100644 --- a/docs/skills/index.md +++ b/docs/skills/index.md @@ -4,7 +4,7 @@ description: Lazy-load manifest for Bluefin Server skills. Load this file after metadata: type: index status: stable - last_updated: "2026-09-27" + last_updated: "2026-09-28" --- # docs/skills — Index @@ -37,7 +37,7 @@ This is the lazy-load routing table for agent skills. Keep this file in memory w | [`system-containers.md`](system-containers.md) | Running `systemd-nspawn` toolboxes | System container operation with `machinectl`. | | [`systemd-sysext-extensions.md`](systemd-sysext-extensions.md) | Optional layers via `systemd-sysext` / `systemd-confext` | Extension identity, loading, and version matching. | | [`systemd-sysupdate-verification.md`](systemd-sysupdate-verification.md) | Image-based A/B updates and signed manifests | Release signing, `systemd-sysupdate`, and trust model. | -| [`tpm2-credential-sealing.md`](tpm2-credential-sealing.md) | TPM2-bound first-boot credentials | Credential sealing with `systemd-creds` and TPM2. | +| [`tpm2-credential-sealing.md`](tpm2-credential-sealing.md) | First-boot credentials, root/SSH node access, TPM2 sealing | Provisioning credentials, node access, and sealing with `systemd-creds`. | ## Standing facts diff --git a/docs/skills/tpm2-credential-sealing.md b/docs/skills/tpm2-credential-sealing.md index ed80e4b9..6e5f9b20 100644 --- a/docs/skills/tpm2-credential-sealing.md +++ b/docs/skills/tpm2-credential-sealing.md @@ -4,7 +4,7 @@ description: Securing provisioning credentials (such as hashed root passwords or metadata: type: how-to status: stable - last_updated: "2026-09-26" + last_updated: "2026-09-28" context7-sources: - /systemd/systemd --- @@ -21,8 +21,10 @@ decrypts and routes at boot: | Credential | Consumer | Purpose | |---|---|---| -| `passwd.hashed-password.root` | `systemd-sysusers` | Optional root password hash for break-glass provisioning. | -| `tmpfiles.extra` | `systemd-tmpfiles` | Extra tmpfiles rules, such as writing an operator's SSH `authorized_keys`. | +| `passwd.hashed-password.root`, `passwd.plaintext-password.root` | `systemd-firstboot` | Optional console root password; see [Node access](#node-access). | +| `ssh.authorized_keys.root` | `systemd-tmpfiles` (stock `provision.conf`) | Root's SSH `authorized_keys`; see [Node access](#node-access). | +| `ssh.listen` | `systemd-ssh-generator` | Socket-activated sshd on the given address or port; see [Node access](#node-access). | +| `tmpfiles.extra` | `systemd-tmpfiles` | Extra tmpfiles rules, such as files for other accounts. | | `network.network.*`, `network.netdev.*`, `network.link.*`, `network.conf.*` | `systemd-network-generator` | Static network, routes, virtual devices, and networkd config. | | `network.dns`, `network.search_domains` | `systemd-resolved` | DNS resolver defaults. | | `firstboot.locale`, `firstboot.locale-messages`, `firstboot.keymap`, `firstboot.timezone`, `firstboot.hostname` | `bluefin-firstboot-credentials.service` | Non-interactive locale, keymap, timezone, and hostname setup. | @@ -31,6 +33,59 @@ The stock DHCP network remains installed in `/usr/lib/systemd/network/20-wired.n Credential-generated network files are emitted under `/run/systemd/network/` and can use lower numeric prefixes such as `10-static.network` to override DHCP. +## Node access + +The image ships no password. Root's `/etc/shadow` entry is `!unprovisioned` +(`elements/oci/bluefin-server-usr.bst`), systemd's marker for a root account +nobody has configured: `passwd -S root` reports `L`, console login, `su` and +`sulogin` refuse it, and sshd accepts keys only +(`files/os/ssh/sshd_config.d/bluefin-server.conf`). Access is provisioned per +node: + +- **SSH key:** Ignition `passwd.users` with `name: root` and + `sshAuthorizedKeys` (the path Booty's `bluefin-node.ign` uses; see + Ignition in [ddi-installer.md](ddi-installer.md)), or the + `ssh.authorized_keys.root` credential, whose content is the + `authorized_keys` file. Both write `/root/.ssh/authorized_keys`. + `sshd.service` is disabled by preset; enable it per node in the same + Ignition config (`systemd.units`: `name: sshd.service`, `enabled: true`), + or pass the `ssh.listen` credential (e.g. `22`), for which + `systemd-ssh-generator` socket-activates a per-connection sshd with the + same key-only policy. +- **Console password:** `passwd.hashed-password.root` (a `crypt(5)` hash with + no trailing newline, e.g. `mkpasswd --method=yescrypt | tr -d '\n'`) or + `passwd.plaintext-password.root`. + `systemd-sysusers` cannot apply these, because it only sets passwords for + accounts it creates and root already exists in the factory `/etc/shadow`. + `systemd-firstboot.service` applies them instead: it treats `!unprovisioned` + as unconfigured. Its interactive root password prompt is removed + (`files/os/creds/systemd/system/systemd-firstboot.service.d/`) so a node + without the credential boots unattended and stays locked. + +`systemd-firstboot` runs on first boot only. A diskless node rebuilds `/etc` +from `/usr/share/factory/etc` and is on its first boot every time, so the +credential applies on every boot. An installed node applies it on the first +boot of the installed disk and keeps the result in `/etc/shadow` on the +persistent xfs root; A/B updates replace only the usr, usr-verity and UKI +slots (`files/os/sysupdate.d/`), so the password survives them. A credential +added to an installed node after its first boot is ignored; change the +password with `passwd` instead. + +Deliver the credentials like any other: SMBIOS type 11 or QEMU fw_cfg on VMs, +an Ignition-capable boot server, or encrypted `.cred` files in +`/loader/credentials/` on the ESP (see below). The USB installer needs no +login: `systemd-sysinstall` runs on the console. It does not carry the +installer's credentials over, so place them in `/loader/credentials/` on the +installed disk's ESP before its first boot. + +With root locked, `emergency.target` and `rescue.target` on the booted system +get no shell: `sulogin` reports the locked account and boot continues. Do not +set `SYSTEMD_SULOGIN_FORCE`, which opens a passwordless root shell on the +console; the kernel command line is sealed in the signed UKI, so it cannot be +added at boot either. For break-glass console access, provision a password +credential and `sulogin` asks for it. The initrd never offers a shell; it +prints the errors and reboots. + ## Verify TPM2 device availability ```bash @@ -83,28 +138,23 @@ On bare metal, an operator mounts the ESP partition (e.g. filesystem label `EFI-SYSTEM` or partition type `C12A7328-F81F-11D2-BA4B-00A0C93EC93B`) and places encrypted credential files into `/loader/credentials/`. During boot, `systemd-creds` decrypts them and passes them to matching system consumers. +ESP credentials are untrusted, so systemd only accepts them encrypted; a +`--with-key=null` credential is refused on a machine with a TPM2 and Secure +Boot on. PCR 11 changes with every UKI, so a diskless node that boots each new +release needs its `--tpm2-pcrs=7+11` credentials re-sealed per release. -### SSH key provisioning with tmpfiles.extra - -To provision SSH keys at first boot on bare metal or virtual machines, deliver a -`tmpfiles.extra` credential (for example `/loader/credentials/tmpfiles.extra.cred`). -`systemd-tmpfiles` consumes this credential on first boot. The payload must create -parent directories before writing the file. - -For the `root` account (or the `core` operator account once provisioned via PR #80): - -```text -d /root 0700 root root - -d /root/.ssh 0700 root root - -f~ /root/.ssh/authorized_keys 0600 root root - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTEAAAA... -``` +### SSH key provisioning -Or for `core` (requires the account to already exist in `/etc/passwd` via sysusers): +Deliver root's `authorized_keys` as the `ssh.authorized_keys.root` credential +(for example `/loader/credentials/ssh.authorized_keys.root.cred`); systemd's +stock `provision.conf` tmpfiles rule writes it to `/root/.ssh/authorized_keys`. +For other accounts, use a `tmpfiles.extra` credential; the payload must create +parent directories before writing the file: ```text -d /var/home/core 0700 core core - -d /var/home/core/.ssh 0700 core core - -f~ /var/home/core/.ssh/authorized_keys 0600 core core - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTEAAAA... +d /var/home/alice 0700 alice alice - +d /var/home/alice/.ssh 0700 alice alice - +f~ /var/home/alice/.ssh/authorized_keys 0600 alice alice - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTEAAAA... ``` Example static network credential name: `network.network.10-static`. From ccefc160a258ea1ed499f1fd2e4bbb84e4ca623f Mon Sep 17 00:00:00 2001 From: Jeffrey Sica Date: Mon, 28 Sep 2026 22:00:13 -0500 Subject: [PATCH 4/4] test(dogfood): pass arbitrary credentials and probe root's password state DOGFOOD_CREDS= hands every file in to the guest as an SMBIOS type 11 credential named after the file, so provisioning credentials (passwd.*.root, ssh.authorized_keys.root, ...) can be dogfooded without editing the harness. Every probe now reports root's `passwd -S` status, and the installed-disk probe whether systemd-firstboot ran. Assisted-by: Claude Opus 5.5 via GitHub Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- docs/skills/ddi-installer-build.md | 4 +++- scripts/dogfood-diskless.sh | 7 +++++++ scripts/dogfood-install.sh | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/skills/ddi-installer-build.md b/docs/skills/ddi-installer-build.md index 0d8e1067..d0caf3df 100644 --- a/docs/skills/ddi-installer-build.md +++ b/docs/skills/ddi-installer-build.md @@ -4,7 +4,7 @@ description: Build, export, and dogfood the Bluefin Server image set (OS DDI, si metadata: type: how-to status: stable - last_updated: "2026-09-27" + last_updated: "2026-09-28" context7-sources: - /systemd/systemd - /apache/buildstream @@ -86,6 +86,8 @@ Useful environment variables: - `DOGFOOD_IGNITION=` — pass an Ignition config as the `ignition.config` credential (see `tests/fixtures/ignition/var-on-disk.ign`). +- `DOGFOOD_CREDS=` — pass every file in `` as a system credential + named after the file (SMBIOS type 11). - `DOGFOOD_STATE_DISK=` — attach a persistent second disk (`/dev/vdb`). - `DOGFOOD_VARS=` — persistent UEFI variable store (keeps enrolled keys across runs). diff --git a/scripts/dogfood-diskless.sh b/scripts/dogfood-diskless.sh index e12cd66f..0802bf93 100644 --- a/scripts/dogfood-diskless.sh +++ b/scripts/dogfood-diskless.sh @@ -12,6 +12,7 @@ # --check headless: boot, run a probe, exit 0 if no unit failed # Environment: # DOGFOOD_IGNITION= pass an Ignition config as the ignition.config credential +# DOGFOOD_CREDS= pass every file in as a system credential named after it # DOGFOOD_STATE_DISK= attach a persistent second disk (/dev/vdb), created if missing # DOGFOOD_EXTRA_PROBE= shell snippet appended to the in-guest probe # DOGFOOD_VARS= persistent UEFI variable store (keeps enrolled keys) @@ -119,6 +120,11 @@ fi if [ -n "${DOGFOOD_IGNITION:-}" ]; then qemu+=(-smbios "$(cred ignition.config "${DOGFOOD_IGNITION}")") fi +if [ -n "${DOGFOOD_CREDS:-}" ]; then + for f in "${DOGFOOD_CREDS}"/*; do + if [ -f "${f}" ]; then qemu+=(-smbios "$(cred "${f##*/}" "${f}")"); fi + done +fi echo "Serving ${dir} on :${port}; ${boot} boot of ${ver} (Secure Boot)" if [ "${mode}" != "--check" ]; then @@ -134,6 +140,7 @@ echo "PROBE root=$(findmnt -no FSTYPE /)" echo "PROBE verity=$(veritysetup status usr | sed -n 's/^ *status: *//p')" echo "PROBE os=$(. /usr/lib/os-release; echo "${IMAGE_ID} ${IMAGE_VERSION}")" echo "PROBE var=$(findmnt -no SOURCE,FSTYPE /var)" +echo "PROBE root-passwd=$(passwd -S root 2>&1 | cut -d' ' -f2)" boots=$(( $(cat /var/lib/dogfood-boots 2>/dev/null || echo 0) + 1 )) echo "${boots}" > /var/lib/dogfood-boots echo "PROBE boots=${boots}" diff --git a/scripts/dogfood-install.sh b/scripts/dogfood-install.sh index 91944222..92cd1e7f 100644 --- a/scripts/dogfood-install.sh +++ b/scripts/dogfood-install.sh @@ -41,6 +41,7 @@ cat > "${state}/disk.probe" <<'EOF' echo "PROBE usr-part=$(lsblk -rsno PARTLABEL /dev/mapper/usr | grep bluefin_usr_ | tr '\n' ' ')" echo "PROBE zfs=$(systemctl is-active zfs.target) $(ls /var/lib/extensions 2>/dev/null | tr '\n' ' ')" echo "PROBE boot-entry=$(bootctl status 2>/dev/null | sed -n 's/^ *Current Entry: *//p' | head -n1)" +echo "PROBE firstboot-ran=$(systemctl show -P ConditionResult systemd-firstboot.service)" bootctl list --no-pager 2>/dev/null | sed -n 's/^ *\(title\|id\): */PROBE-LOG \1 /p' systemctl start boot-complete.target 2>/dev/null || true echo "PROBE ukis=$(ls /boot/EFI/Linux 2>/dev/null | tr '\n' ' ')"