Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
fail-fast: false
matrix:
include:
- { target: qemux86-64, distro-release: "2026", distro-channel: next }
- { target: qemux86-64, distro-release: "2024", distro-channel: next }
uses: avocado-linux/actions/.github/workflows/extension-test.yml@v1
with:
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to avocado-ext-sshd-dev are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.1]

### Added
- sshd also reads authorized keys from `/var/lib/ssh/authorized_keys.d/<user>`
(`/etc/ssh/sshd_config.d/50-avocado-authorized-keys.conf`). The root
filesystem is read-only, so `~/.ssh/authorized_keys` cannot be written for
root; `/var` is writable and survives reboots and OS updates. Ship keys with
the runtime's `var_files` or write them at provisioning.
- CI builds against the 2026 feed as well as 2024.

## [0.1.0]

### Added
Expand Down
2 changes: 1 addition & 1 deletion avocado.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ supported_targets: '*'

extensions:
avocado-ext-sshd-dev:
version: 0.1.0
version: 0.1.1
release: r0
summary: SSH server with root login
description: SSH server that allows root login with no password. DO NOT USE IN PRODUCTION.
Expand Down
13 changes: 13 additions & 0 deletions overlay/etc/ssh/sshd_config.d/50-avocado-authorized-keys.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Avocado: read keys from /var as well as ~/.ssh.
#
# The root filesystem is read-only, so a home directory on it (root's is
# /root) cannot hold ~/.ssh/authorized_keys. /var/lib/ssh/authorized_keys.d/
# 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.
Comment on lines +5 to +9

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

#
# sshd keeps the first value it sees and sshd_config Includes this directory
# first, so this takes precedence over sshd_config's own AuthorizedKeysFile.
AuthorizedKeysFile .ssh/authorized_keys /var/lib/ssh/authorized_keys.d/%u
Loading