Repository navigation
Read authorized keys from /var as well as ~/.ssh, 0.1.1 - #3
mobileoverlord wants to merge 1 commit into
Conversation
The root filesystem is read-only, so ~/.ssh/authorized_keys cannot be
written for root (/root) and the extension gave no other place for keys.
Ship an sshd drop-in, /etc/ssh/sshd_config.d/50-avocado-authorized-keys.conf:
AuthorizedKeysFile .ssh/authorized_keys /var/lib/ssh/authorized_keys.d/%u
/var is writable and survives reboots and OS updates. Keys are per user,
so one account's keys never open another; ship them with the runtime's
var_files or write them at provisioning. Authentication policy is
unchanged. sshd_config Includes sshd_config.d first, so the drop-in wins.
Also builds against the 2026 feed in CI, alongside 2024.
Verified on a Jetson AGX Orin (2026): sshd -T reports the new
AuthorizedKeysFile, and a key in /var/lib/ssh/authorized_keys.d/root logs
in on an sshd with password auth off (Accepted publickey) while a client
without the key is refused.
| # is writable and survives reboots and OS updates; put each user's keys in | ||
| # a file named for the user (e.g. .../authorized_keys.d/root), shipped with | ||
| # the runtime's var_files or written at provisioning. Per-user files keep one | ||
| # account's keys from opening another. StrictModes applies: the directory and | ||
| # files must be owned by root (or the user) and not group/world writable. |
There was a problem hiding this comment.
sshd will refuse keys shipped with runtime var_files on a Linux build host.
avocado-cli copies runtime var_files with cp -a (src/commands/runtime/build.rs:2439), then packs the var image with mkfs.btrfs -r (src/commands/runtime/var_image.rs:611). Both steps keep the uid, gid and mode of the host file. On a Linux host the key file belongs to the developer (for example uid 1000). On Ubuntu the default umask is 002, so the files are 0664 and the directories are 0775. StrictModes requires the key file and each parent directory up to / to be owned by root or the login user, with no group or world write.
How it occurs: the user follows the CHANGELOG, adds keys/root to var_files, builds and provisions. Key login then fails. The only sign is Authentication refused: bad ownership or modes in the journal. This extension also permits empty-password root login, so the user may not see the failure until they turn password auth off. The test in the PR wrote the key on the device as root, so it did not hit this path. I found this by reading the code and did not reproduce it on a device.
Suggested fix: ship overlay/usr/lib/tmpfiles.d/avocado-sshd-keys.conf:
d /var/lib/ssh/authorized_keys.d 0755 root root -
Z /var/lib/ssh/authorized_keys.d ~0755 root root -
The ~ keeps key files at 0644 and sets the directory to 0755. The d line also creates the directory for users who write keys at provisioning. Add systemd-tmpfiles --create /usr/lib/tmpfiles.d/avocado-sshd-keys.conf to on_merge so the fix applies without a reboot.
jetm
left a comment
There was a problem hiding this comment.
I read the full diff: the new sshd drop-in, the 2026 CI matrix entry, the version bump to 0.1.1 and the CHANGELOG entry. The drop-in sets AuthorizedKeysFile to the usual per-user .ssh/authorized_keys plus /var/lib/ssh/authorized_keys.d/%u, which gives each account its own key file on the writable /var. The version in avocado.yaml matches the CHANGELOG heading, and the new matrix line has the same shape as the existing 2024 one. I did not build or run anything, so the sshd -T and publickey login results in the description are the author's report and not something I reproduced. I found no blocking issue.
This is a comment, not an approval: branch_protection_unsafe
|
@mobileoverlord ext-bringup's README (avocado-linux/ext-bringup#1) documents /var/lib/ssh/authorized_keys.d/root as the key location for the console-to-SSH step and says it needs avocado-ext-sshd-dev 0.1.1 or newer. I'm holding the bringup 0.1.0 tag until this lands and 0.1.1 is published. @nicksinas's StrictModes point is covered there: the keys are created as root from the console, so the directory and the file are root-owned and not group- or world-writable. Separately, avocado-os has an sshd access-policy drop-in that I could send here as a follow-up. Which sshd config copy gets read depends on how the image was assembled, and a drop-in keeps the policy independent of that. Do you want it? |
The root filesystem is read-only, so ~/.ssh/authorized_keys cannot be
written for root (/root) and the extension gave no other place for keys.
Ship an sshd drop-in, /etc/ssh/sshd_config.d/50-avocado-authorized-keys.conf:
/var is writable and survives reboots and OS updates. Keys are per user,
so one account's keys never open another; ship them with the runtime's
var_files or write them at provisioning. Authentication policy is
unchanged. sshd_config Includes sshd_config.d first, so the drop-in wins.
Also builds against the 2026 feed in CI, alongside 2024.
Verified on a Jetson AGX Orin (2026): sshd -T reports the new
AuthorizedKeysFile, and a key in /var/lib/ssh/authorized_keys.d/root logs
in on an sshd with password auth off (Accepted publickey) while a client
without the key is refused.