Skip to content

deploy stack ssh env setup

πŸ€– OpenCode for Michael Conrad edited this page Nov 25, 2026 · 2 revisions

deploy-stack.sh β€” operator setup (ssh key, ssh-copy-id, env file)

deploy-stack.sh carries no person's account name anywhere (the 2026-11-24 deploy-identity decision; spec: DEPLOY_ENV_SPEC.md). The stack host's ssh target (STACK_HOST) comes from an untracked operator env file on your machine. This runbook takes a new operator from zero to a deploy-ready workstation: ssh key, authorized key on the stack host, the env file, and verification.

Pre-requisite: a provisioned account on the stack host

The deploy target is (the prod serving host β€” see the repo's SOP.md Host-roles section). Your account there must be provisioned with:

  • membership of the group that can run docker (compose build/up, container inspect/run);
  • write access to /srv/cherokeedictionary (build context + compose);
  • write access to /srv/caddy/caddy/Caddyfile (the blue-green flip).

Request the account provisioning in cherokeelanguage-devops first β€” it is not something the repo or this runbook can grant.

1. Generate an ssh key (skip if you already have one)

ls ~/.ssh/id_ed25519.pub 2>/dev/null || ssh-keygen -t ed25519 -C "$(whoami)@$(hostname)"

Accept the default location; a passphrase is strongly recommended. On Windows, ssh-keygen ships with the OpenSSH client / Git Bash.

2. Authorize the key on the stack host (ssh-copy-id)

ssh-copy-id <deploy-user>@<stack-host>

<deploy-user> is your provisioned account name on the stack host (ask whoever provisions the account). ssh-copy-id appends your public key to the host's ~/.ssh/authorized_keys; it will ask for the password one last time. If a different key name is wanted, use: ssh-copy-id -i ~/.ssh/<key>.pub <deploy-user>@<stack-host>

3. Create the operator env file

The script checks both locations, first match wins:

# Path Scope
1 ./deploy-stack.env (repo root) local checkout override
2 ~/.config/cherokeedictionary/deploy.env per-operator default

Normal per-operator home is location 2:

mkdir -p ~/.config/cherokeedictionary
cp /path/to/cherokeedictionary/deploy-stack.env.example ~/.config/cherokeedictionary/deploy.env
chmod 600 ~/.config/cherokeedictionary/deploy.env
# edit: STACK_HOST=<deploy-user>@<stack-host>

The file is plain KEY=value shell. STACK_HOST is required; the optional gate/build knobs (GATE_BASE_URL, GATE_BOOT_TIMEOUT, GATE_POLL, BUILD_TIMEOUT) may be overridden here too. Define only the documented keys β€” the file is sourced as shell, so a stray variable could shadow a script internal. A repo-local ./deploy-stack.env copy is gitignored β€” never commit it (git status must not list it; a force-added one defeats the ignore rule).

4. Verify β€” WITHOUT deploying

Do not use deploy-stack.sh as your first connectivity test: it ships the build context and rebuilds on the host. Verify the pieces:

# (a) the env file parses and yields the target
bash -c 'set -a; . ~/.config/cherokeedictionary/deploy.env; set +a; echo "STACK_HOST=$STACK_HOST"'

# (b) the key authenticates without a prompt (BatchMode forbids one)
#     β€” in a fresh shell, after the same source line as (a):
. ~/.config/cherokeedictionary/deploy.env
ssh -o BatchMode=yes "$STACK_HOST" 'echo ok'

(Using a repo-local ./deploy-stack.env instead? Source ./deploy-stack.env in (b) and everything downstream is identical.)

Then confirm the deploy-grade privileges on the same target:

ssh -o BatchMode=yes "$STACK_HOST" \
  'docker version --format "{{.Server.Version}}" && test -w /srv/cherokeedictionary && test -w /srv/caddy/caddy/Caddyfile && echo "deploy privileges: ok"'

All three green β†’ ./deploy-stack.sh will find your config (it prints operator config: <path>) and can run.

Troubleshooting

  • ERROR: no operator deploy config β€” STACK_HOST is not set β€” the script found neither file, or the file exists with no STACK_HOST= line. Re-check the two paths above (repo-local name is deploy-stack.env, the ~/.config one is deploy.env).
  • Permission denied (publickey) in step 4 β€” the key was not copied (repeat Β§2), a non-default key file exists (repeat Β§2 with -i ~/.ssh/<key>.pub), or a passphrase is set without an unlocked agent: run ssh-add, or configure AddKeysToAgent yes in ~/.ssh/config.
  • Password prompt in step 4 β€” BatchMode disallows prompts, so a prompt means key auth is not working (fix per the previous bullet, diagnose with ssh -v).
  • Host key verification failed β€” first-ever connect to the host: connect once interactively and accept the fingerprint.
  • ERROR: operator config '...' is not valid KEY=value shell β€” the env file must be plain KEY=value shell lines (LF line endings; no non-shell syntax β€” e.g. a Windows-edited CRLF file fails here).
  • cannot ... /srv/... in the privileges probe β€” the provisioned account lacks write access to the build/compose or Caddyfile path; back to the devops provisioning request.

References