diff --git a/secure-delivery/WORK_LOG.md b/secure-delivery/WORK_LOG.md index b7a87e4..5132872 100644 --- a/secure-delivery/WORK_LOG.md +++ b/secure-delivery/WORK_LOG.md @@ -44,3 +44,7 @@ - At inspection, staging.myfileagent.tech and app.myfileagent.tech did not resolve via the Droplet resolver. Existing Caddy routes serve Gitea, Jenkins and Grafana; no pricing routes added yet. - Expanded secret scan to the checked-out repository (excluding Git metadata, disposable test environment and generated reports); direct agent test returned zero findings and exit 0. This change still requires a Jenkins run after publication. + +## Jenkins validation #3 and deployment preparation +- Jenkins assignment8-validation #3 succeeded for commit dd7c12c519b14f59d9842ebd6d417e7117d92e94, including tests, dependency audit, expanded repository secret scan, Ansible syntax, image build and HIGH/CRITICAL image scan; report archived. Evidence: https://ci.myfileagent.tech/job/assignment8-validation/3/console . Build context was 7.68 kB after excluding test venv. +- Verified agent-to-host private SSH gateway 172.20.0.1 matches the host ED25519 fingerprint SHA256:CXrEv4+pv1jTwBtwxdTGlouS6I4H1Q6TkKbvQrbacu0. Prepared inventory and verified public known_hosts entry; dedicated account and Jenkins SSH credential are not yet configured. Prepared private deployment key and a reviewable administrator setup script, not yet executed. Gitea registry endpoint returns 401 as expected for authentication; registry push/pull has not been verified. diff --git a/secure-delivery/agent/setup-deploy-account.sh b/secure-delivery/agent/setup-deploy-account.sh new file mode 100755 index 0000000..239fee3 --- /dev/null +++ b/secure-delivery/agent/setup-deploy-account.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# Run as root after reviewing the deployment privilege scope. +set -eu +[ "$(id -u)" -eq 0 ] || { echo "Run as root" >&2; exit 1; } +key=/home/codex/myfileagent-gitea/secrets/assignment8-deploy.pub +[ -s "$key" ] || { echo "Deployment public key missing" >&2; exit 1; } +if ! id a8deploy >/dev/null 2>&1; then useradd -m -s /bin/bash a8deploy; fi +home=$(getent passwd a8deploy | cut -d: -f6) +[ "$home" = /home/a8deploy ] || { echo "Unexpected account home" >&2; exit 1; } +install -d -o a8deploy -g a8deploy -m 700 "$home/.ssh" +touch "$home/.ssh/authorized_keys" +chown a8deploy:a8deploy "$home/.ssh/authorized_keys" +chmod 600 "$home/.ssh/authorized_keys" +grep -qxF "$(cat "$key")" "$home/.ssh/authorized_keys" || cat "$key" >> "$home/.ssh/authorized_keys" +tmp=$(mktemp) +trap 'rm -f "$tmp"' EXIT +printf '%s\n' 'a8deploy ALL=(root) NOPASSWD: ALL' > "$tmp" +visudo -cf "$tmp" >/dev/null +install -o root -g root -m 440 "$tmp" /etc/sudoers.d/90-assignment8-deploy +echo 'Assignment 8 deploy account prepared.' diff --git a/secure-delivery/ansible/inventory.ini b/secure-delivery/ansible/inventory.ini index 18494a3..8c6dc5d 100644 --- a/secure-delivery/ansible/inventory.ini +++ b/secure-delivery/ansible/inventory.ini @@ -1,3 +1,2 @@ [delivery] -# Replace address and user; verify the SSH host key before first use. -startup ansible_host=REPLACE_DROPLET_ADDRESS ansible_user=deploy +startup ansible_host=172.20.0.1 ansible_user=a8deploy diff --git a/secure-delivery/ansible/known_hosts b/secure-delivery/ansible/known_hosts new file mode 100644 index 0000000..1169eeb --- /dev/null +++ b/secure-delivery/ansible/known_hosts @@ -0,0 +1,2 @@ +# 172.20.0.1:22 SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13.20 +172.20.0.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMLfpbUktZ4Q6KaAKA5quOhM/rc9asSxloPJFOsIv2/B