Two deploy mistakes from today that looked like something else:
Run under sudo: ssh read root's ~/.ssh/config instead of the user's, so a custom Port 7625 disappeared and the deploy failed with ssh: connect to host triton port 22: Connection refused.
Run from an outdated checkout: the workstation's main was two commits behind origin/main, so the redeploy shipped the 0.5.0 agent again, and the dashboard kept saying "agent 0.5.0 is older than 0.6.0" after a deploy that had looked fine.
Changes
agent/deploy.sh:
Refuses under sudo (running as root with SUDO_USER set), names the user to run it as, and stops before contacting any host. Nothing in it needs local root: install.sh runs under sudo on each host. A real root login is still allowed.
Checks the checkout before deploying: fetches its upstream branch (20s limit, no credential prompts) and, if the checkout is behind:
on a terminal, asks Deploy anyway? [y/N];
otherwise refuses with a pointer to the new --allow-outdated flag;
with --dry-run, only warns.
A failed fetch warns and deploys. Being ahead of upstream, no upstream branch, or not being in a git checkout skips the check.
docs/agents.md: explains both checks and lists --allow-outdated.
Testing
make test: all pass, including 16 new deploy tests.
Sudo guard: refused under sudo (and nothing contacted), root login allowed, SUDO_USER set but not root allowed.
Checkout check, against real throwaway git repos (bare origin + a clone pushing a newer commit): up to date deploys quietly, behind refuses without a terminal (nothing deployed), --allow-outdated deploys with a warning, --dry-run only warns, unreachable upstream warns and deploys, ahead is fine, no upstream skips the check.
The existing deploy tests also run inside a git checkout, so normal flows are covered with the check active.
## Problem
Two deploy mistakes from today that looked like something else:
1. **Run under sudo**: ssh read root's `~/.ssh/config` instead of the user's, so a custom `Port 7625` disappeared and the deploy failed with `ssh: connect to host triton port 22: Connection refused`.
2. **Run from an outdated checkout**: the workstation's `main` was two commits behind `origin/main`, so the redeploy shipped the 0.5.0 agent again, and the dashboard kept saying "agent 0.5.0 is older than 0.6.0" after a deploy that had looked fine.
## Changes
`agent/deploy.sh`:
- **Refuses under sudo** (running as root with `SUDO_USER` set), names the user to run it as, and stops before contacting any host. Nothing in it needs local root: `install.sh` runs under sudo on each host. A real root login is still allowed.
- **Checks the checkout before deploying**: fetches its upstream branch (20s limit, no credential prompts) and, if the checkout is behind:
- on a terminal, asks `Deploy anyway? [y/N]`;
- otherwise refuses with a pointer to the new `--allow-outdated` flag;
- with `--dry-run`, only warns.
A failed fetch warns and deploys. Being ahead of upstream, no upstream branch, or not being in a git checkout skips the check.
`docs/agents.md`: explains both checks and lists `--allow-outdated`.
## Testing
- `make test`: all pass, including 16 new deploy tests.
- Sudo guard: refused under sudo (and nothing contacted), root login allowed, `SUDO_USER` set but not root allowed.
- Checkout check, against real throwaway git repos (bare origin + a clone pushing a newer commit): up to date deploys quietly, behind refuses without a terminal (nothing deployed), `--allow-outdated` deploys with a warning, `--dry-run` only warns, unreachable upstream warns and deploys, ahead is fine, no upstream skips the check.
- The existing deploy tests also run inside a git checkout, so normal flows are covered with the check active.
- shellcheck wasn't available locally; CI runs it.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
patrick
added 2 commits 2026-11-01 00:46:59 +00:00
Under sudo, ssh reads root's config and keys, so a custom Port silently
disappears and the deploy fails with "connect to host ... port 22:
Connection refused". deploy.sh needs no root locally (install.sh runs
under sudo on each host), so it now refuses when run as root via sudo,
naming the user to run it as. A real root login is still allowed.
Deploying from a checkout behind its upstream ships an older agent than
the server expects, and the dashboard keeps saying "agent is older" after
a deploy that looked fine. deploy.sh now fetches the upstream (20s limit)
and, if the checkout is behind, asks on a terminal or refuses otherwise;
--allow-outdated deploys anyway and --dry-run only warns. A failed fetch
warns and carries on; no checkout or no upstream skips the check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
Two deploy mistakes from today that looked like something else:
~/.ssh/configinstead of the user's, so a customPort 7625disappeared and the deploy failed withssh: connect to host triton port 22: Connection refused.mainwas two commits behindorigin/main, so the redeploy shipped the 0.5.0 agent again, and the dashboard kept saying "agent 0.5.0 is older than 0.6.0" after a deploy that had looked fine.Changes
agent/deploy.sh:Refuses under sudo (running as root with
SUDO_USERset), names the user to run it as, and stops before contacting any host. Nothing in it needs local root:install.shruns under sudo on each host. A real root login is still allowed.Checks the checkout before deploying: fetches its upstream branch (20s limit, no credential prompts) and, if the checkout is behind:
Deploy anyway? [y/N];--allow-outdatedflag;--dry-run, only warns.A failed fetch warns and deploys. Being ahead of upstream, no upstream branch, or not being in a git checkout skips the check.
docs/agents.md: explains both checks and lists--allow-outdated.Testing
make test: all pass, including 16 new deploy tests.SUDO_USERset but not root allowed.--allow-outdateddeploys with a warning,--dry-runonly warns, unreachable upstream warns and deploys, ahead is fine, no upstream skips the check.🤖 Generated with Claude Code