ephemeral: Add writable tmpfs overlay over /root/.ssh - #334
Conversation
Explain this more? Like If so...yeah, this seems fine but what I think would ultimately be a lot cleaner here is we write the keys into |
Exactly, pure composefs with plain /root and /home directories. I'm composing a base image like this, with derived images deciding what to mount there. Fully transient images would mount a pure tmpfs and fetch ssh keys on boot, while more "regular" images would likely do a bind mount for /home and an overlay mount for /root. Maybe something that could later be handled by initramfs-setup via config?
Maybe, but I think this would involve modifying sshd's config (for instance via drop-in). But IIRC it wouldn't work for dropbear, which has the path hardcoded.. |
Which, now that I think of it, might break the .ssh overlay mount :/ any suggestion here? EDIT: I think it actually satisfies all the kernel overlay requirements, so shouldn't cause any problem. |
You mean for the final bootc-installed system? Mount a pure tmpfs...where? Over I guess backing up, while I think we should support with bcvk having |
|
I think what woudl help for this patch is a |
Maybe over I think a fully transient
I considered doing that for debugging, but I'd like to avoid including the mount in the base image. I was injecting a systemd mount unit for ephemeral runs, but that's not supported in libvirt or to-disk. |
dda612b to
ac1fafc
Compare
Some fully transient bootc images might have a read-only /root, which breaks ssh key injection. Overlaying a writable tmpfs over /root/.ssh allows the keys to be injected without changing the write permissions for the /root directory or shadowing existing keys. The implementation mirrors what's currently done for /etc, with an additional bcvk-root-ssh-overlay.service unit embedded in the CPIO archive that gets appended to the initramfs. Since there might be secrets in /root/.ssh, we're ensuring the overlay directories are created with mode 0700. In conventional bootc images, /root is a symlink to /var/roothome, which is created by tmpfiles.d after the pivot to the final root filesystem. Because the target directory doesn't exist during the initramfs stage, attempting to mount an overlay over /root/.ssh would fail. But since /var/roothome is writable in these systems, the overlay is unnecessary and can be safely skipped. Closes: bootc-dev#331 Signed-off-by: Renato Caldas <renato@silkmicro.com>
That's a great catch, thanks! I think the CI is failing because of https://rustsec.org/advisories/RUSTSEC-2026-0173.html, probably worth doing a cargo update? |
Some fully transient bootc images might have a read-only /root, which breaks ssh key injection. Overlaying a writable tmpfs over /root/.ssh allows the keys to be injected without changing the write permissions for the /root directory or shadowing existing keys.
The implementation mirrors what's currently done for /etc, with an additional bcvk-root-ssh-overlay.service unit embedded in the CPIO archive that gets appended to the initramfs. Since there might be secrets in /root/.ssh, we're ensuring the overlay directories are created with mode 0700.
In conventional bootc images, /root is a symlink to /var/roothome, which is created by tmpfiles.d after the pivot to the final root filesystem. Because the target directory doesn't exist during the initramfs stage, attempting to mount an overlay over /root/.ssh would fail. But since /var/roothome is writable in these systems, the overlay is unnecessary and can be safely skipped.
Closes: #331