feat: root adds the ssh keys, mkosi ssh for the test VM

The setup no longer asks for an ssh key. Root logs in on the console and
adds keys for claude and root to /var/lib/agent. Root may log in with
ssh, and its home is a tmpfs that is wiped at every boot. The test VM
uses mkosi ssh instead of a forwarded port, so the agent.ssh-key
credential is gone.

Also mount /var with noatime, move STYLE.md into AGENTS.md and rewrite
comments to start with the name of what they describe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Job79andClaude Opus 5.5 committed 2026-11-19 19:10:54 +01:00
1 parent 8aeb448936
commit db8fb0d5a4
15 files changed
+218 -180

No files matched your search

+62 -53
View File
@@ -5,6 +5,9 @@
# Claude Code package repository. The root filesystem, /etc included, is
# read-only and replaced whole by updates. All state lives on /var. Claude
# can't change the OS, so it runs its tools in containers.
# mkosi.extra/etc/claude-code/ sets Claude Code up for that:
# managed-settings.json lets it run without permission prompts, and CLAUDE.md
# tells it about this machine.
[Distribution]
Distribution=fedora
@@ -15,30 +18,34 @@ Format=disk
ImageId=agent
OutputDirectory=mkosi.output
SplitArtifacts=uki,partitions
# Lists the packages and versions in the image, to tell which builds a CVE
# affects. .gitea/workflows/os.yml publishes it with the image.
# ManifestFormat lists the packages and versions in the image, to tell which
# builds a CVE affects. .gitea/workflows/os.yml publishes it with the image.
ManifestFormat=json
[Build]
# Keeps downloaded packages between builds, also when mkosi runs in a
# throwaway container (AGENTS.md). dnf still installs the newest versions.
# PackageCacheDirectory keeps downloaded packages between builds, also when
# mkosi runs in a throwaway container (AGENTS.md). dnf still installs the
# newest versions.
PackageCacheDirectory=mkosi.pkgcache
[Content]
Bootable=yes
Bootloader=systemd-boot
# - kernel-core no drivers or firmware beyond what VMs need
# - systemd-container systemd-pull, which systemd-sysupdate downloads by
# - gnupg2 checks the signature of updates
# - util-linux, shadow-utils console login, setup, newuidmap for rootless podman
# - systemd-pam login sessions: Claude's user manager and its
# D-Bus, which rootless podman needs
# - openssh-server ssh login for the user (keys only)
# - zram-generator-defaults compressed swap in RAM
# - podman, podman-docker containers for Claude's toolchains (also as docker)
# - claude-code from mkosi.sandbox/etc/yum.repos.d
# - git-core, openssh-clients Claude Code uses git and pushes over ssh
# - the rest basic command-line tools Claude uses on the host
# Packages is systemd with its network services, plus:
# - kernel-core has no drivers or firmware beyond what VMs need.
# - systemd-container has systemd-pull, which systemd-sysupdate downloads with.
# - gnupg2 checks the signature of updates.
# - systemd-boot-unsigned is the boot loader, which mkosi signs.
# - util-linux and shadow-utils give the console login, the setup and
# newuidmap for rootless podman.
# - systemd-pam gives login sessions: Claude's user manager and its D-Bus,
# which rootless podman needs.
# - openssh-server lets you log in with ssh keys.
# - zram-generator-defaults sets up compressed swap in RAM.
# - podman and podman-docker run Claude's toolchains in containers.
# - claude-code comes from mkosi.sandbox/etc/yum.repos.d.
# - git-core and openssh-clients let Claude Code use git and push over ssh.
# - The rest are basic command-line tools Claude uses on the host.
Packages=
kernel-core
systemd
@@ -70,17 +77,18 @@ Packages=
iproute
WithDocs=no
Locale=C.UTF-8
# Name UKIs the way systemd-sysupdate names the ones it installs.
# UnifiedKernelImageFormat names UKIs the way systemd-sysupdate names the ones
# it installs.
UnifiedKernelImageFormat=%i_%v
# - console= show the console on screen and on the serial port
# - systemd.machine_id= take the machine ID from the VM's firmware;
# mkosi.extra/etc/machine-id is empty, so no boot
# counts as the first
# - systemd.firstboot=no agent-setup asks its own questions
# - SYSTEMD_DEFAULT_MOUNT_ systemd handles mount changes at most 5 times per
# RATE_LIMIT_BURST= second and holds back mounts once it hits that. At
# boot that delays / and /var by up to a second each.
# The kernel passes this to systemd as environment.
# KernelCommandLine sets:
# - console= shows the console on the screen and on the serial port.
# - systemd.machine_id=firmware takes the machine ID from the VM's firmware.
# mkosi.extra/etc/machine-id is empty, so no boot counts as the first.
# - systemd.firstboot=no leaves the questions to agent-setup.
# - SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST lets systemd handle more mount
# changes per second. At the default of 5, it holds back mounts at boot and
# delays / and /var by up to a second each. The kernel passes it to systemd
# as environment.
KernelCommandLine=
console=tty0
console=ttyS0,115200n8
@@ -88,7 +96,8 @@ KernelCommandLine=
systemd.machine_id=firmware
systemd.firstboot=no
SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST=50
# The initrd only needs to find and mount the disks of a VM.
# KernelInitrdModules are the modules the initrd needs to find and mount the
# disks of a VM.
KernelInitrdModules=
virtio_blk
virtio_scsi
@@ -97,10 +106,10 @@ KernelInitrdModules=
dm-verity
erofs
ext4
# All modules but the hardware drivers, then the drivers a VM needs (disks,
# network, screen) and those of rootless podman's networks (pasta). The last
# matching line wins. Keyboard, USB and a basic screen are built into the
# kernel.
# KernelModules keeps all modules but the hardware drivers, then the drivers a
# VM needs (disks, network, screen) and those of rootless podman's networks
# (pasta). The last matching line wins. Keyboard, USB and a basic screen are
# built into the kernel.
KernelModules=
/*
-/drivers/*
@@ -116,16 +125,16 @@ KernelModules=
virtio-gpu
veth
tun
# - System.map only for debugging the kernel
# - udev hwdb hardware names and quirks, nothing a VM needs
# - homed, userdbd, unused services
# nsresourced
# - sshd-keygen sshd uses one host key, kept on /var
# (mkosi.extra/etc/ssh/sshd_config.d)
# - /afs mount point for the AFS network filesystem
# - /buildroot dnf's lock file, left by mkosi: it passes dnf5
# persistdir=/buildroot/var/lib/dnf and dnf5 puts
# the install root in front of it again
# RemoveFiles drops what the image doesn't use:
# - System.map is only for debugging the kernel.
# - The udev hwdb holds hardware names and quirks, nothing a VM needs.
# - homed, userdbd and nsresourced are unused services.
# - sshd-keygen would write host keys to the read-only /etc. sshd uses one host
# key on /var instead (mkosi.extra/etc/ssh/sshd_config.d).
# - /afs is the mount point for the AFS network filesystem.
# - /buildroot holds dnf's lock file, left by mkosi: it passes dnf5
# persistdir=/buildroot/var/lib/dnf and dnf5 puts the install root in front
# of it again.
RemoveFiles=
/usr/lib/modules/*/System.map
/usr/lib/udev/hwdb.bin
@@ -138,25 +147,25 @@ RemoveFiles=
/buildroot
[Validation]
# Sign systemd-boot and the UKI for Secure Boot, and put our keys on the ESP.
# SecureBoot signs systemd-boot and the UKI, and puts our keys on the ESP.
# systemd-boot enrolls them at first boot if the firmware is in setup mode (no
# keys enrolled; in Proxmox, an EFI disk without pre-enrolled keys).
# mkosi.key is the SECUREBOOT_KEY secret, which .gitea/workflows/os.yml writes.
# keys enrolled; in Proxmox, an EFI disk without pre-enrolled keys). mkosi.key
# is the SECUREBOOT_KEY secret, which .gitea/workflows/os.yml writes.
SecureBoot=yes
SecureBootKey=mkosi.key
SecureBootCertificate=mkosi.crt
[Runtime]
# For testing with mkosi vm. It does the setup itself (the agent.* credentials,
# mkosi.extra/usr/libexec/agent-setup). Its console is hvc0, which the UKI
# doesn't use: with Secure Boot, systemd-stub ignores the console= mkosi
# passes. So the serial port joins that console, and replaces mkosi's network
# to forward ssh to port 2222. Ephemeral boots a copy, so test runs don't
# change the built image.
# Runtime sets up the test VM of mkosi vm (AGENTS.md). Ephemeral boots a copy,
# so test runs don't change the built image. Credentials answer the setup
# (mkosi.extra/usr/libexec/agent-setup). mkosi ssh logs in as root with
# mkosi.key, which mkosi also authorizes for root in the VM.
Ephemeral=yes
CPUs=4
RAM=8G
RuntimeSize=40G
RuntimeNetwork=none
QemuArgs=-serial chardev:console -nic user,model=virtio-net-pci,hostfwd=tcp::2222-:22
Credentials=agent.password=test agent.hostname=agent-test mkosi.credentials/
# QemuArgs joins the serial port to the console mkosi vm shows (hvc0). The UKI
# doesn't use hvc0: with Secure Boot, systemd-stub ignores the console= mkosi
# passes.
QemuArgs=-serial chardev:console
Credentials=agent.password=root agent.hostname=agent-test