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
84 changes: 84 additions & 0 deletions ebclfsa_aarch64/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ load("//:qemu_config.bzl", "qemu_config")
IMAGE_PACKAGES = [
":network_config_deb",
":sshd_config_deb",
":ssh_host_keys_deb",
]

SSH_HOST_KEY_ALGORITHMS = [
"rsa",
"ecdsa",
"ed25519",
]

exports_files(
Expand Down Expand Up @@ -81,6 +88,83 @@ pkg_deb(
visibility = ["//visibility:public"],
)

# The toolkit's first-boot key generator skips keys whose public files exist.
genrule(
name = "ssh_host_keys",
outs = [
"ssh-host-keys/ssh_host_%s_key%s" % (algorithm, suffix)
for algorithm in SSH_HOST_KEY_ALGORITHMS
for suffix in [
"",
".pub",
]
],
cmd = "mkdir -p $(RULEDIR)/ssh-host-keys && " +
" && ".join([
"ssh-keygen -q -t %s -N '' -C '' -f $(RULEDIR)/ssh-host-keys/ssh_host_%s_key" % (algorithm, algorithm)
for algorithm in SSH_HOST_KEY_ALGORITHMS
]),
local = True,
tags = ["no-remote-cache"],
)

filegroup(
name = "ssh_host_public_keys",
srcs = [
"ssh-host-keys/ssh_host_%s_key.pub" % algorithm
for algorithm in SSH_HOST_KEY_ALGORITHMS
],
visibility = ["//visibility:public"],
)

pkg_tar(
name = "ssh_host_private_keys_tar",
srcs = [
"ssh-host-keys/ssh_host_%s_key" % algorithm
for algorithm in SSH_HOST_KEY_ALGORITHMS
],
mode = "0600",
package_dir = "/etc/ssh",
strip_prefix = "ssh-host-keys",
tags = ["no-remote-cache"],
)

pkg_tar(
name = "ssh_host_public_keys_tar",
srcs = [
"ssh-host-keys/ssh_host_%s_key.pub" % algorithm
for algorithm in SSH_HOST_KEY_ALGORITHMS
],
mode = "0644",
package_dir = "/etc/ssh",
strip_prefix = "ssh-host-keys",
tags = ["no-remote-cache"],
)

pkg_tar(
name = "ssh_host_keys_tar",
tags = ["no-remote-cache"],
deps = [
":ssh_host_private_keys_tar",
":ssh_host_public_keys_tar",
],
)

pkg_deb(
name = "ssh_host_keys_deb",
architecture = "all",
data = ":ssh_host_keys_tar",
depends = ["ebclfsa-openssh-server-keys-crinit"],
description = "Development SSH server host keys for integration testing",
homepage = "https://github.com/eclipse-score/os_images",
maintainer = "Eclipse S-CORE contributors <score-dev@eclipse.org>",
package = "score-itf-ssh-host-keys",
replaces = ["ebclfsa-openssh-server-keys-crinit"],
tags = ["no-remote-cache"],
version = "1.0",
visibility = ["//visibility:public"],
)

# Builds the image with KAS/Isar in a privileged container. This takes a long
# time, so the target is only built when explicitly requested.
genrule(
Expand Down
14 changes: 12 additions & 2 deletions ebclfsa_aarch64/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ only built when selected explicitly.
| `:qemu_config` | Generated QEMU configuration with the image's SSH key path |
| `:ssh_target_key` | Development private key generated with the image |
| `:network_config_deb` | The `score-network-config` Debian package |
| `:ssh_host_keys_deb` | Generated SSH server host keys as a Debian package |

## Requirements

- An x86_64 Linux host with Docker, `dpkg-deb` (from `dpkg`), and permission to
- An x86_64 Linux host with Docker, `dpkg-deb` (from `dpkg`), `ssh-keygen`
(from `openssh-client`), and permission to
run privileged containers. The Docker daemon must see the Bazel output
directory at the same absolute path as the build process (no remote daemon).
- Network access to GitHub, GHCR and the package repositories referenced by the
Expand Down Expand Up @@ -85,6 +87,14 @@ rejected. Packages must be compatible with the arm64 image, and their
dependencies must be available from the configured repositories or supplied in
the same list.

The `score-itf-ssh-host-keys` package supplies RSA, ECDSA and Ed25519 host
key pairs at build time, replacing the toolkit's empty private-key placeholders.
This avoids generating them at boot. Images built from the same package share
these keys; Bazel may reuse the package across builds. The private keys are
present in the disk image and build outputs, so they are not secret and must
not be trusted for host authentication. Use these images only for isolated
testing. Generate unique host keys for each device before any non-test use.

## Tests

The ping, multicast, SSH authentication, no-disk, and DHCP QEMU integration
Expand Down Expand Up @@ -142,7 +152,7 @@ These keys are deliberately public development credentials: anyone downloading
the release can log in as root on a reachable image. Use only on isolated test
networks, never reuse the keys elsewhere, and replace the authorized key and
disable passwordless login before any non-test deployment. SSH server host
private keys are not included in the archives.
private keys are included in the disk image inside each archive.

Both platform builds must succeed before any assets are published. Re-running a
successful workflow replaces assets with the same names. If releases are created
Expand Down
2 changes: 1 addition & 1 deletion ebclfsa_aarch64/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ for artifact in "${artifacts[@]}"; do
done

if [[ "$release" == true ]]; then
# Publish only the development login key, never SSH server host keys.
# The disk image contains development SSH server host keys.
tar --sparse -czf "$output/$image.tar.gz" -C "$deploy" \
"$image.wic" "$image-vmlinux" "$image.spdx.json" "$image-ssh-target-key"
cp -L "$deploy/$sdk.tar.gz" "$deploy/$sdk.spdx.json" "$output/"
Expand Down
2 changes: 2 additions & 0 deletions tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ py_itf_test(
py_itf_test(
name = "ebclfsa_qemu_test",
srcs = [
"test_ebclfsa_ssh_host_keys.py",
"test_multicast.py",
"test_no_disk.py",
"test_ping.py",
Expand All @@ -155,6 +156,7 @@ py_itf_test(
"//ebclfsa_aarch64:image",
"//ebclfsa_aarch64:kernel",
"//ebclfsa_aarch64:qemu_config",
"//ebclfsa_aarch64:ssh_host_public_keys",
"//ebclfsa_aarch64:ssh_target_key",
],
plugins = ["@score_itf//score/itf/plugins:qemu_plugin"],
Expand Down
48 changes: 48 additions & 0 deletions tests/test_ebclfsa_ssh_host_keys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

import os
from pathlib import Path


def test_packaged_host_keys_survive_boot(target):
built_keys = (
Path(os.environ["TEST_SRCDIR"])
/ os.environ["TEST_WORKSPACE"]
/ "ebclfsa_aarch64"
/ "ssh-host-keys"
)

for algorithm in ("rsa", "ecdsa", "ed25519"):
key = f"/etc/ssh/ssh_host_{algorithm}_key"

# Check that key packages are installed
exit_code, output = target.execute(f"dpkg-query -S {key} {key}.pub")
assert exit_code == 0, output
assert output.splitlines() == [
f"score-itf-ssh-host-keys: {key}".encode(),
f"score-itf-ssh-host-keys: {key}.pub".encode(),
]

# Check file permissions
exit_code, output = target.execute(f"stat -c '%U:%G %a' {key} {key}.pub")
assert exit_code == 0, output
assert output.splitlines() == [b"root:root 600", b"root:root 644"]

# Check key content is the same as the built keys
exit_code, private_public = target.execute(f"ssh-keygen -y -f {key}")
assert exit_code == 0, private_public
exit_code, public = target.execute(f"cat {key}.pub")
assert exit_code == 0, public
assert public == (built_keys / f"ssh_host_{algorithm}_key.pub").read_bytes()
assert private_public.split()[:2] == public.split()[:2]
Loading