ci(deploy): pin the deploy key to one forced command; self-update runs the new setup.sh

The 10-27 incident showed what an unrestricted root deploy key is worth to an
attacker. The CI key is now installed on the box as
restrict,command="/usr/local/sbin/agentbbs-ci-deploy", so it gets no shell,
scp, sftp, pty or forwarding.

- deploy/ci-deploy.sh (installed by setup.sh): verbs `arch`, `upload
  agentbbs|ascii-live` (ELF on stdin, size-capped, root-only staging dir) and
  `deploy main|master` (app secrets as NAME=<base64> on stdin, allowlisted).
  It does what the old inline heredoc did: sync to origin, pause the
  self-update timer, install binaries, exec setup.sh SKIP_BUILD=1.
- deploy.yml: uses those verbs instead of scp + `sudo bash -s`.
- self-update.sh: reset to origin before exec'ing setup.sh, so a setup.sh
  change takes effect on the first timer run instead of the second.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Anthony Ettinger 2026-11-02 09:20:11 +00:00
parent eb8e9ae9c5
commit 2d21feba24
4 changed files with 128 additions and 49 deletions

View file

@ -642,6 +642,12 @@ else
systemctl daemon-reload
fi
# ---- 7c. CI deploy forced command --------------------------------------------
# root's authorized_keys pins the GitHub Actions deploy key to this one script
# (restrict,command="/usr/local/sbin/agentbbs-ci-deploy"); keep it in sync with
# the repo so the CI verbs (arch / upload / deploy) always match deploy.yml.
install -m 0755 "$SRC_DIR/deploy/ci-deploy.sh" /usr/local/sbin/agentbbs-ci-deploy
# ---- 8. move admin OpenSSH to ADMIN_SSH_PORT (before agentbbs takes :22) -----
log "moving admin OpenSSH to :${ADMIN_SSH_PORT}"
install -d -m 0755 /etc/ssh/sshd_config.d