Prevent interactive SSH in release CI
This commit is contained in:
7 files changed
+81
-28
No files matched your search
+15
-10
@@ -37,12 +37,15 @@ through that container's Docker mount table. The release wrapper and
|
||||
control-plane tests both use it because bind mount paths passed to the socket
|
||||
are resolved by the runner host daemon, not inside the Actions job container.
|
||||
|
||||
The SSH checkout steps pin the current `git.faumaray.ru` RSA host key. Its
|
||||
verified fingerprint is
|
||||
The SSH checkout steps and `scripts/lib/component-ssh.sh` pin the current
|
||||
`git.faumaray.ru` RSA host key. Its verified fingerprint is
|
||||
`SHA256:fugBYnqAnqmTLsGpafVgQF9gPQzJqps7uHvs48blg2A`. If the Gitea SSH host key
|
||||
is intentionally rotated, verify the new fingerprint through an independent
|
||||
administrator channel and update `ssh-known-hosts` in all three workflows.
|
||||
Never work around a rotation by disabling strict host-key checking.
|
||||
administrator channel and update `ssh-known-hosts` in all three workflows plus
|
||||
the shared helper. Component Git commands use `BatchMode=yes` and strict host
|
||||
checking, so missing credentials or a changed host key fail instead of waiting
|
||||
for interactive runner input. Never work around a rotation by disabling strict
|
||||
host-key checking.
|
||||
|
||||
The Docker-capable runner executes only protected `main` pushes, manual runs,
|
||||
scheduled nightlies, and signed release tags. The container CI workflow does
|
||||
@@ -58,16 +61,18 @@ Enable Actions and add these repository secrets:
|
||||
|
||||
| Secret | Purpose |
|
||||
| --- | --- |
|
||||
| `RELEASE_CHECKOUT_SSH_KEY` | Read-only SSH key used for root, component, and `release-feed` checkouts. Grant it access to every private component repository before cutover. |
|
||||
| `RELEASE_CHECKOUT_SSH_KEY` | Release-bot SSH key used to read every private component/dependency repository and to fast-forward the protected Echoion `release-feed` branch. |
|
||||
| `RELEASE_BOT_TOKEN` | PAT owned by a dedicated bot. It needs read access to every component repository plus release/tag write access in this repository. It does not need `release-feed` write access. |
|
||||
| `RELEASE_TAG_ALLOWED_SIGNERS` | Complete OpenSSH `allowed_signers` lines for maintainers allowed to publish `v*` tags. |
|
||||
| `RELEASE_FEED_ED25519_PUBLIC_KEY` | PEM public key matching the component-feed signing key. It verifies independently published components without exposing signing authority to the product workflow. |
|
||||
|
||||
Component checkouts use SSH with `persist-credentials: false`. Release API
|
||||
operations use the bot PAT, but Git fetches and pushes never rewrite remotes to
|
||||
HTTPS. The component-feed private signing key must not be present in the
|
||||
Echoion product repository, Git, runner images, Actions variables, or release
|
||||
assets.
|
||||
Root product checkouts use pinned SSH with `persist-credentials: false`.
|
||||
Independent workflows check out their current repository with Gitea's job
|
||||
token and the public Echoion release tools over HTTPS; their private
|
||||
component/dependency reads and `release-feed` push use the pinned SSH helper.
|
||||
Release API operations use the bot PAT. The component-feed private signing key
|
||||
must not be present in the Echoion product repository, Git, runner images,
|
||||
Actions variables, or release assets.
|
||||
|
||||
## Independent component repositories
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ jobs:
|
||||
EXPECTED_REF: ${{ gitea.ref }}
|
||||
EXPECTED_REF_TYPE: ${{ gitea.ref_type }}
|
||||
TAG_ALLOWED_SIGNERS: ${{ secrets.RELEASE_TAG_ALLOWED_SIGNERS }}
|
||||
ECHOION_COMPONENT_SSH_KEY: ${{ secrets.RELEASE_CHECKOUT_SSH_KEY }}
|
||||
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }}
|
||||
API_URL: ${{ gitea.api_url }}
|
||||
REPOSITORY: ${{ gitea.repository }}
|
||||
|
||||
@@ -72,7 +72,9 @@ The following Gitea Actions variables are required:
|
||||
|
||||
The following secrets are required in each component repository:
|
||||
|
||||
- `RELEASE_CHECKOUT_SSH_KEY`
|
||||
- `RELEASE_CHECKOUT_SSH_KEY` (read access to every private component and
|
||||
dependency repository, plus write access to Echoion's protected
|
||||
`release-feed` branch)
|
||||
- `RELEASE_TAG_ALLOWED_SIGNERS`
|
||||
- `RELEASE_BOT_TOKEN`
|
||||
- `RELEASE_FEED_ED25519_PRIVATE_KEY`
|
||||
|
||||
@@ -11,6 +11,8 @@ if [[ -z ${ECHOION_COMPONENT_SSH_KEY:-} ]]; then
|
||||
fi
|
||||
|
||||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)
|
||||
# shellcheck source=scripts/lib/component-ssh.sh
|
||||
source "$script_dir/lib/component-ssh.sh"
|
||||
workspace=$(realpath -m -- "$1")
|
||||
dependency_workspace=
|
||||
if (($# == 2)); then
|
||||
@@ -18,16 +20,12 @@ if (($# == 2)); then
|
||||
fi
|
||||
credential_dir=$(mktemp -d)
|
||||
cleanup() {
|
||||
rm -f -- "$credential_dir/key" "$credential_dir/known_hosts"
|
||||
rmdir -- "$credential_dir"
|
||||
rm -rf -- "$credential_dir"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
umask 077
|
||||
printf '%s\n' "$ECHOION_COMPONENT_SSH_KEY" >"$credential_dir/key"
|
||||
printf '%s\n' \
|
||||
'git.faumaray.ru ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCzZEz9JLrzk6oLiloSbueAN28vYL58Y/dTHBgRuBMMib9IJ1aDJShhr3kwC9sfOT0AzK0uwcMAqCAIkwJwttde8dIg0Mee0cmB/1JkoqFF4X3MUGD1r3nk8SSZNhIiPqo16hDF9Hf3FkovztIlBVntkyP9Iy9hYfP818Tiq3yRXROGdHjR7IfY4jR2QGfGrd/RtvPGExVqusxidy141240A8aRAwMFUqFdEvmXWjizrtCUqcrL/k1GEh0yJzbCdNOVUI6OuWd8tPluSBvmmeoNpKnCSl4Mkg36HObbOyrsme0asZqjcj0od65WYWApMPN0pUqhNu2CP83Nfor2VFwkdPRwe7cAZ0OD/8wyT6Hz5q1wWgf82y4tYDoDRYsd8JU86eebkJ07T5nCrEeC4Sj+qT4S5xv/kECAhxyP4QGnunORnY2fYsdNGzpPvbMN7gHe9UcIcQdOIgV3wrR1qpMVNcd8AEC2A3TRv/jzMCHSjmGGpgiy1Db2CZAjp5+PcjNmjvoPNN0NiA9X4rIVSeTfflWnDRmeNRJeZa73StjpU17EcAf97COUQPGWJQDgpJqINSpYU50fuaLBfzKnIRuiHjKQmyKe/zgRSmulnYFYM3AJfn8Ykg2VvkUQGvCt1+fqYiUa1iVFuwPP3ZigYF1mOZRpPnos5kaNmlB01q2sZw==' \
|
||||
>"$credential_dir/known_hosts"
|
||||
export GIT_SSH_COMMAND="ssh -i $credential_dir/key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$credential_dir/known_hosts"
|
||||
echoion_configure_component_ssh \
|
||||
"$credential_dir" "$ECHOION_COMPONENT_SSH_KEY"
|
||||
python3 "$script_dir/sync-components.py" \
|
||||
--workspace "$workspace" \
|
||||
--update
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
# Keep the Gitea SSH trust root in one place for every non-interactive
|
||||
# component/dependency checkout. Rotate this only after independently
|
||||
# verifying the replacement server fingerprint.
|
||||
readonly ECHOION_GITEA_SSH_RSA_HOST_KEY='git.faumaray.ru ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCzZEz9JLrzk6oLiloSbueAN28vYL58Y/dTHBgRuBMMib9IJ1aDJShhr3kwC9sfOT0AzK0uwcMAqCAIkwJwttde8dIg0Mee0cmB/1JkoqFF4X3MUGD1r3nk8SSZNhIiPqo16hDF9Hf3FkovztIlBVntkyP9Iy9hYfP818Tiq3yRXROGdHjR7IfY4jR2QGfGrd/RtvPGExVqusxidy141240A8aRAwMFUqFdEvmXWjizrtCUqcrL/k1GEh0yJzbCdNOVUI6OuWd8tPluSBvmmeoNpKnCSl4Mkg36HObbOyrsme0asZqjcj0od65WYWApMPN0pUqhNu2CP83Nfor2VFwkdPRwe7cAZ0OD/8wyT6Hz5q1wWgf82y4tYDoDRYsd8JU86eebkJ07T5nCrEeC4Sj+qT4S5xv/kECAhxyP4QGnunORnY2fYsdNGzpPvbMN7gHe9UcIcQdOIgV3wrR1qpMVNcd8AEC2A3TRv/jzMCHSjmGGpgiy1Db2CZAjp5+PcjNmjvoPNN0NiA9X4rIVSeTfflWnDRmeNRJeZa73StjpU17EcAf97COUQPGWJQDgpJqINSpYU50fuaLBfzKnIRuiHjKQmyKe/zgRSmulnYFYM3AJfn8Ykg2VvkUQGvCt1+fqYiUa1iVFuwPP3ZigYF1mOZRpPnos5kaNmlB01q2sZw=='
|
||||
|
||||
echoion_configure_component_ssh() {
|
||||
if (($# != 2)); then
|
||||
echo "usage: echoion_configure_component_ssh CREDENTIAL_DIR PRIVATE_KEY" >&2
|
||||
return 2
|
||||
fi
|
||||
|
||||
local credential_dir=$1
|
||||
local private_key=$2
|
||||
if [[ -z $private_key ]]; then
|
||||
echo "component SSH private key is empty" >&2
|
||||
return 2
|
||||
fi
|
||||
|
||||
local ssh_key="$credential_dir/component-ssh-key"
|
||||
local known_hosts="$credential_dir/component-known-hosts"
|
||||
mkdir -p -- "$credential_dir"
|
||||
chmod 0700 "$credential_dir"
|
||||
printf '%s\n' "$private_key" >"$ssh_key"
|
||||
printf '%s\n' "$ECHOION_GITEA_SSH_RSA_HOST_KEY" >"$known_hosts"
|
||||
chmod 0600 "$ssh_key" "$known_hosts"
|
||||
|
||||
printf -v GIT_SSH_COMMAND \
|
||||
'ssh -i %q -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=%q' \
|
||||
"$ssh_key" "$known_hosts"
|
||||
export GIT_SSH_COMMAND
|
||||
}
|
||||
@@ -2,4 +2,21 @@
|
||||
set -euo pipefail
|
||||
|
||||
root_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd -P)"
|
||||
exec python3 "${root_dir}/scripts/prepare_release.py" "$@"
|
||||
credential_dir=
|
||||
cleanup() {
|
||||
if [[ -n $credential_dir ]]; then
|
||||
rm -rf -- "$credential_dir"
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if [[ -n ${ECHOION_COMPONENT_SSH_KEY:-} ]]; then
|
||||
# shellcheck source=scripts/lib/component-ssh.sh
|
||||
source "$root_dir/scripts/lib/component-ssh.sh"
|
||||
credential_dir=$(mktemp -d)
|
||||
umask 077
|
||||
echoion_configure_component_ssh \
|
||||
"$credential_dir" "$ECHOION_COMPONENT_SSH_KEY"
|
||||
fi
|
||||
|
||||
python3 "${root_dir}/scripts/prepare_release.py" "$@"
|
||||
@@ -12,6 +12,8 @@ script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)
|
||||
root=$(cd -- "$script_dir/.." && pwd -P)
|
||||
source_root=$(pwd -P)
|
||||
configuration=$(realpath -- "$1")
|
||||
# shellcheck source=scripts/lib/component-ssh.sh
|
||||
source "$script_dir/lib/component-ssh.sh"
|
||||
|
||||
required_commands=(
|
||||
aws
|
||||
@@ -99,22 +101,16 @@ cleanup() {
|
||||
trap cleanup EXIT
|
||||
|
||||
umask 077
|
||||
ssh_key="$secrets_dir/release-ssh"
|
||||
known_hosts="$secrets_dir/known-hosts"
|
||||
feed_key="$secrets_dir/feed-ed25519.pem"
|
||||
commit_key="$secrets_dir/feed-commit-key"
|
||||
allowed_signers="$secrets_dir/tag-allowed-signers"
|
||||
printf '%s\n' "$ECHOION_COMPONENT_SSH_KEY" >"$ssh_key"
|
||||
printf '%s\n' "$ECHOION_FEED_PRIVATE_KEY" >"$feed_key"
|
||||
printf '%s\n' "$ECHOION_FEED_COMMIT_SIGNING_KEY" >"$commit_key"
|
||||
printf '%s\n' "$ECHOION_RELEASE_TAG_ALLOWED_SIGNERS" >"$allowed_signers"
|
||||
printf '%s\n' \
|
||||
'git.faumaray.ru ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCzZEz9JLrzk6oLiloSbueAN28vYL58Y/dTHBgRuBMMib9IJ1aDJShhr3kwC9sfOT0AzK0uwcMAqCAIkwJwttde8dIg0Mee0cmB/1JkoqFF4X3MUGD1r3nk8SSZNhIiPqo16hDF9Hf3FkovztIlBVntkyP9Iy9hYfP818Tiq3yRXROGdHjR7IfY4jR2QGfGrd/RtvPGExVqusxidy141240A8aRAwMFUqFdEvmXWjizrtCUqcrL/k1GEh0yJzbCdNOVUI6OuWd8tPluSBvmmeoNpKnCSl4Mkg36HObbOyrsme0asZqjcj0od65WYWApMPN0pUqhNu2CP83Nfor2VFwkdPRwe7cAZ0OD/8wyT6Hz5q1wWgf82y4tYDoDRYsd8JU86eebkJ07T5nCrEeC4Sj+qT4S5xv/kECAhxyP4QGnunORnY2fYsdNGzpPvbMN7gHe9UcIcQdOIgV3wrR1qpMVNcd8AEC2A3TRv/jzMCHSjmGGpgiy1Db2CZAjp5+PcjNmjvoPNN0NiA9X4rIVSeTfflWnDRmeNRJeZa73StjpU17EcAf97COUQPGWJQDgpJqINSpYU50fuaLBfzKnIRuiHjKQmyKe/zgRSmulnYFYM3AJfn8Ykg2VvkUQGvCt1+fqYiUa1iVFuwPP3ZigYF1mOZRpPnos5kaNmlB01q2sZw==' \
|
||||
>"$known_hosts"
|
||||
chmod 0600 "$ssh_key" "$known_hosts" "$feed_key" "$commit_key" \
|
||||
"$allowed_signers"
|
||||
chmod 0600 "$feed_key" "$commit_key" "$allowed_signers"
|
||||
echoion_configure_component_ssh \
|
||||
"$secrets_dir" "$ECHOION_COMPONENT_SSH_KEY"
|
||||
openssl pkey -in "$feed_key" -noout
|
||||
export GIT_SSH_COMMAND="ssh -i $ssh_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$known_hosts"
|
||||
|
||||
git clone --filter=blob:none --branch release-feed --single-branch \
|
||||
"$ECHOION_FEED_REPOSITORY" "$feed_state"
|
||||
|
||||
Reference in new issue
Block a user