@senior: Wire up ssh node1 … in the agent workflow (read-only swarm diagnostics) #11

Merged
ffaerber merged 1 commits from ai/issue-10 into main 2026-07-03 11:17:50 +02:00

Summary

Added a new workflow step that, before opencode run, sets up a read-only ssh node1 client so agents can run ssh node1 <cmd> (matching the homelab opencode.json allowlist patterns). It writes SSH_PRIV_KEY to ~/.ssh/agent_node1 (600) and adds a Host node1 SSH config alias using SWARM_HOST/SWARM_USER (config 600, ~/.ssh 700). The step no-ops cleanly when the swarm secrets are absent, so this shared workflow still works for repos that don't define them.

Changes

  • .gitea/workflows/agent.yml: new step "Set up read-only SSH alias node1 (swarm diagnostics)" placed between "Install opencode + provider config" and "Inspect / fetch image attachments", so the alias is ready before any agent (including comment-mode agents that may invoke bash via opencode) runs.
  • Secrets (SWARM_HOST/SWARM_USER/SSH_PRIV_KEY) are passed via env: and never inlined in shell; the key is never printed.
  • Graceful no-op when any swarm secret is empty — non-swarm repos are unaffected.

Safety confirmation (per issue)

The provider-level ~/.config/opencode/opencode.json written in the "Install opencode + provider config" step contains only provider and mcp keys — no permission block. It therefore does not override the target repo's project-level opencode.json, does not blanket-approve bash, and does not re-allow ssh *. The read-only boundary enforced by the homelab opencode.json (deny ssh * + specific allow ssh node1 …, last-match-wins, compatible with --auto) remains the real safety boundary, now backed by a working ssh node1 command.

Verification

Real verification is post-merge in a repo with the swarm secrets: ssh node1 docker service ls should return swarm state, and ssh node1 docker service rm <x> should be denied by the opencode permission layer. That's a manual check for @ffaerber (or a follow-up comment) — not something @qa's browser flow can validate.


Resolves #10 · 🤖 @senior

## Summary Added a new workflow step that, before `opencode run`, sets up a read-only `ssh node1` client so agents can run `ssh node1 <cmd>` (matching the homelab `opencode.json` allowlist patterns). It writes `SSH_PRIV_KEY` to `~/.ssh/agent_node1` (600) and adds a `Host node1` SSH config alias using `SWARM_HOST`/`SWARM_USER` (config 600, `~/.ssh` 700). The step no-ops cleanly when the swarm secrets are absent, so this shared workflow still works for repos that don't define them. ## Changes - `.gitea/workflows/agent.yml`: new step "Set up read-only SSH alias `node1` (swarm diagnostics)" placed between "Install opencode + provider config" and "Inspect / fetch image attachments", so the alias is ready before any agent (including comment-mode agents that may invoke `bash` via opencode) runs. - Secrets (`SWARM_HOST`/`SWARM_USER`/`SSH_PRIV_KEY`) are passed via `env:` and never inlined in shell; the key is never printed. - Graceful no-op when any swarm secret is empty — non-swarm repos are unaffected. ## Safety confirmation (per issue) The provider-level `~/.config/opencode/opencode.json` written in the "Install opencode + provider config" step contains **only** `provider` and `mcp` keys — no `permission` block. It therefore does not override the target repo's project-level `opencode.json`, does not blanket-approve `bash`, and does not re-allow `ssh *`. The read-only boundary enforced by the homelab `opencode.json` (`deny ssh *` + specific `allow ssh node1 …`, last-match-wins, compatible with `--auto`) remains the real safety boundary, now backed by a working `ssh node1` command. ## Verification Real verification is post-merge in a repo with the swarm secrets: `ssh node1 docker service ls` should return swarm state, and `ssh node1 docker service rm <x>` should be denied by the opencode permission layer. That's a manual check for @ffaerber (or a follow-up comment) — not something @qa's browser flow can validate. --- Resolves #10 · 🤖 @senior
gitea-actions bot added 1 commit 2026-07-03 11:13:47 +02:00
ffaerber merged commit 343a422233 into main 2026-07-03 11:17:50 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gitea/agents#11