own-VPS control-plane probe (Adapter.UnitActive) checks host keys against ~/.ssh/known_hosts, not the app-scoped own-VPS file — false MITM refusal on droplet IP reuse #458

Closed
opened 2026-08-12 00:50:17 +00:00 by ben · 2 comments
Owner

Failure

Journey leg control-plane went red: founding: gateway deploy: founding: probe ourcloud-control-plane.service on the gateway: clan: probe ourcloud-control-plane.service on gateway over ssh: exit status 255: ... WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED ... Offending ED25519 key in /home/dev/.ssh/known_hosts:95 ... Host key verification failed.

Run: test-results/drive-droplet/20260812T003918Z (rehearsal drive, red leg supply/control-plane, sig 404124947736).

Evidence

  • The gateway droplet is a fresh full-install; NixOS minted brand-new SSH host keys on first boot — logs/droplet-journal.txt:900-904, ed25519 fingerprint SHA256:1TjAh9pZ9jisl7y04IbvZeeGNNa5DS91k1TVjevnGyU.
  • The own-VPS connect/pairing path correctly trusted the new key: the run's scoped state/own-vps/known_hosts already holds exactly that fingerprint (confirmed via ssh-keygen -lf), and logs/founding-state.log:178,183,188 shows pairing (gateway paired and approved as node node-req-0001) and gateway-deploy start succeeding after the reboot that rotated the key.
  • The step that actually fails, internal/clan/adapter.go:119-151 Adapter.UnitActive, builds its ssh argv independently:
    args := []string{"-o", "BatchMode=yes", "-o", "StrictHostKeyChecking=accept-new"}
    if a.sshIdentityFile != "" { args = append(args, "-i", a.sshIdentityFile) }
    args = append(args, "ssh://"+m.Deploy.TargetHost, "systemctl", "is-active", unit)
    out, runErr := exec.CommandContext(ctx, "ssh", args...).CombinedOutput()
    
    No -o UserKnownHostsFile=... — it falls back to the ambient ~/.ssh/known_hosts on the box running the drive. The error's Offending ED25519 key in /home/dev/.ssh/known_hosts:95 is a stale entry from an earlier droplet that previously held IP 170.64.151.241 (DigitalOcean IP reuse across rehearsal runs). StrictHostKeyChecking=accept-new only auto-trusts a host with no existing entry — a changed key on an already-known host is a hard refusal, which is exactly what fired.
  • Caller: internal/founding/deploy.go:332-334 wraps this into founding: probe %s on the gateway.
  • The sibling path that gets this right: internal/fleetwire/fleetwire.go:73-102 (RemoteTarget/sshOpts) passes -o UserKnownHostsFile=<scoped path>, fed from ownVPSKnownHostsPath() in app/helper/cmd/helper/wiring_prod.go:105-107 (ADR 0152), and reused at wiring_prod.go:300,360,402. UnitActive never goes through fleetwire.Target — it's a second, independent ssh-argv builder that drifted from the first.

Suspected layer

internal/clan (Adapter.UnitActive's ad hoc ssh invocation), wired from app/helper/cmd/helper/wiring_prod.go (newClanAdapter).

What plugging it needs

  1. Give Adapter a known-hosts-file option (mirroring the existing WithSSHIdentityFile in adapter.go:74-90) and have UnitActive append -o UserKnownHostsFile=<path> when set.
  2. Wire it at the founding-specific newClanAdapter call site with the same ownVPSKnownHostsPath() already used for fleetwire.RemoteTarget — but this needs a scoping decision: newClanAdapter also backs the standalone real-fleet-hardware face (wiring_prod.go:64-68 says its own SSH trust is unrelated to the own-VPS one), so the new option should NOT be applied there. Consider instead routing UnitActive through the same fleetwire.Target/RemoteTarget abstraction the connect/pairing path already uses, so there's one source of truth for ssh options instead of two argv builders that can drift again.
  3. UnitActive isn't behind the CLI seam (raw exec.CommandContext), so no existing test can catch this — internal/clan/adapter_test.go has no UnitActive coverage. Whatever lands needs either a small command-runner seam or an integration-level assertion that the known_hosts flag is actually in the argv.

Related in-code refs: #437 (own-VPS forward-loopback deploy target), #443 (truthful not-active vs transport-error split) — both cited in UnitActive's doc comment at adapter.go:110-118.

Not self-fixed: this signature already had one self-fix land on this leg and still recurred, and the correct fix requires a scope judgment across newClanAdapter's two callers (own-VPS vs standalone fleet-hardware) rather than a mechanical constant/selector change, with no targeted test to verify it here.

drive 20260812T003918Z red at supply: journey leg "control-plane" went red: founding: gateway deploy: founding: probe ourcloud-control-plane.service on the gateway: clan: probe ourcloud-control-plane.service on gateway over ssh: exit stat @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the EDN key sent by the remote host is SHAN:NTjAhNpZNjislNyNIbvZeeGNNaNDSNkNTVjevnGyU. Please contact your system administrator. Add correct host key in /home/dev/.ssh/known_hosts to get rid of this message. Offending EDN key in /home/dev/.ssh/known_hosts:N remove with: ssh-keygen -f '/home/dev/.ssh/known_hosts' -R 'N.N.N.N' Host key for N.N.N.N has changed and you have requested strict checking. Host key verification failed.
evidence: test-results/…/20260812T003918Z/ on matou-workstation (legs.json, droplet-journal.txt, trace)

## Failure Journey leg `control-plane` went red: `founding: gateway deploy: founding: probe ourcloud-control-plane.service on the gateway: clan: probe ourcloud-control-plane.service on gateway over ssh: exit status 255: ... WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED ... Offending ED25519 key in /home/dev/.ssh/known_hosts:95 ... Host key verification failed.` Run: `test-results/drive-droplet/20260812T003918Z` (rehearsal drive, red leg `supply`/`control-plane`, sig `404124947736`). ## Evidence - The gateway droplet is a fresh full-install; NixOS minted brand-new SSH host keys on first boot — `logs/droplet-journal.txt:900-904`, ed25519 fingerprint `SHA256:1TjAh9pZ9jisl7y04IbvZeeGNNa5DS91k1TVjevnGyU`. - The own-VPS connect/pairing path correctly trusted the new key: the run's scoped `state/own-vps/known_hosts` already holds exactly that fingerprint (confirmed via `ssh-keygen -lf`), and `logs/founding-state.log:178,183,188` shows pairing (`gateway paired and approved as node node-req-0001`) and gateway-deploy start succeeding *after* the reboot that rotated the key. - The step that actually fails, `internal/clan/adapter.go:119-151` `Adapter.UnitActive`, builds its ssh argv independently: ```go args := []string{"-o", "BatchMode=yes", "-o", "StrictHostKeyChecking=accept-new"} if a.sshIdentityFile != "" { args = append(args, "-i", a.sshIdentityFile) } args = append(args, "ssh://"+m.Deploy.TargetHost, "systemctl", "is-active", unit) out, runErr := exec.CommandContext(ctx, "ssh", args...).CombinedOutput() ``` No `-o UserKnownHostsFile=...` — it falls back to the ambient `~/.ssh/known_hosts` on the box running the drive. The error's `Offending ED25519 key in /home/dev/.ssh/known_hosts:95` is a stale entry from an earlier droplet that previously held IP `170.64.151.241` (DigitalOcean IP reuse across rehearsal runs). `StrictHostKeyChecking=accept-new` only auto-trusts a host with *no* existing entry — a changed key on an already-known host is a hard refusal, which is exactly what fired. - Caller: `internal/founding/deploy.go:332-334` wraps this into `founding: probe %s on the gateway`. - The sibling path that gets this right: `internal/fleetwire/fleetwire.go:73-102` (`RemoteTarget`/`sshOpts`) passes `-o UserKnownHostsFile=<scoped path>`, fed from `ownVPSKnownHostsPath()` in `app/helper/cmd/helper/wiring_prod.go:105-107` (ADR 0152), and reused at `wiring_prod.go:300,360,402`. `UnitActive` never goes through `fleetwire.Target` — it's a second, independent ssh-argv builder that drifted from the first. ## Suspected layer `internal/clan` (`Adapter.UnitActive`'s ad hoc ssh invocation), wired from `app/helper/cmd/helper/wiring_prod.go` (`newClanAdapter`). ## What plugging it needs 1. Give `Adapter` a known-hosts-file option (mirroring the existing `WithSSHIdentityFile` in `adapter.go:74-90`) and have `UnitActive` append `-o UserKnownHostsFile=<path>` when set. 2. Wire it at the founding-specific `newClanAdapter` call site with the same `ownVPSKnownHostsPath()` already used for `fleetwire.RemoteTarget` — but this needs a scoping decision: `newClanAdapter` also backs the standalone real-fleet-hardware face (`wiring_prod.go:64-68` says its own SSH trust is unrelated to the own-VPS one), so the new option should NOT be applied there. Consider instead routing `UnitActive` through the same `fleetwire.Target`/`RemoteTarget` abstraction the connect/pairing path already uses, so there's one source of truth for ssh options instead of two argv builders that can drift again. 3. `UnitActive` isn't behind the `CLI` seam (raw `exec.CommandContext`), so no existing test can catch this — `internal/clan/adapter_test.go` has no `UnitActive` coverage. Whatever lands needs either a small command-runner seam or an integration-level assertion that the known_hosts flag is actually in the argv. Related in-code refs: `#437` (own-VPS forward-loopback deploy target), `#443` (truthful not-active vs transport-error split) — both cited in `UnitActive`'s doc comment at `adapter.go:110-118`. Not self-fixed: this signature already had one self-fix land on this leg and still recurred, and the correct fix requires a scope judgment across `newClanAdapter`'s two callers (own-VPS vs standalone fleet-hardware) rather than a mechanical constant/selector change, with no targeted test to verify it here. drive `20260812T003918Z` red at `supply`: `journey leg "control-plane" went red: founding: gateway deploy: founding: probe ourcloud-control-plane.service on the gateway: clan: probe ourcloud-control-plane.service on gateway over ssh: exit stat @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the EDN key sent by the remote host is SHAN:NTjAhNpZNjislNyNIbvZeeGNNaNDSNkNTVjevnGyU. Please contact your system administrator. Add correct host key in /home/dev/.ssh/known_hosts to get rid of this message. Offending EDN key in /home/dev/.ssh/known_hosts:N remove with: ssh-keygen -f '/home/dev/.ssh/known_hosts' -R 'N.N.N.N' Host key for N.N.N.N has changed and you have requested strict checking. Host key verification failed.` evidence: `test-results/…/20260812T003918Z/` on matou-workstation (legs.json, droplet-journal.txt, trace) <!-- rehearsal-sig: 404124947736 -->
Author
Owner

swarm-claim host=matou-dev-server-01 run=4852
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=4852 (automated multi-host claim — lowest live claim id works this ticket)
Author
Owner

close-report for #458 — status success

✅ close-report gates passed — every claim verified against main; closing.

envelope
{
  "issue": 458,
  "status": "success",
  "commits": [
    "2cde70acf7e4a770bdc756a5680ce3a4f6650072"
  ],
  "changed_files": [
    "STATUS.md",
    "app/helper/cmd/helper/wiring_prod.go",
    "internal/clan/adapter.go",
    "internal/clan/adapter_test.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci --command go test ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci --command go vet ./app/helper/...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Adapter.UnitActive checks host keys against the app-scoped own-VPS file, not ~/.ssh/known_hosts": "internal/clan/adapter.go: UnitActive appends `-o UserKnownHostsFile=<path>` when a.sshKnownHostsFile is set; wired to ownVPSKnownHostsPath() at founding's newClanAdapter in wiring_prod.go",
    "Adapter gains a known-hosts-file option mirroring WithSSHIdentityFile": "internal/clan/adapter.go: WithSSHKnownHostsFile(path) AdapterOption + sshKnownHostsFile field",
    "Option wired at founding's newClanAdapter (own-VPS) but NOT the standalone fleet-hardware face": "wiring_prod.go: newClanAdapter(identity, knownHosts) — clan port passes ownVPSKnownHostsPath(), newClanFace() passes \"\"",
    "UnitActive is testable (command-runner seam / argv assertion) — no prior coverage": "internal/clan/adapter.go: sshRun transport seam (default execSSH); internal/clan/adapter_test.go: TestUnitActive_PinsScopedKnownHostsFile asserts the flag present on the pinned face and absent on the bare face, TestUnitActive_TruthfulFalseVsTransportError proves the systemctl-word read still holds over the seam"
  },
  "summary": "clan.Adapter.UnitActive now pins its ssh host-key check to the app-scoped own-VPS known-hosts file (via a new instance-scoped WithSSHKnownHostsFile + sshRun seam), wired only on founding's own-VPS face, ending the false MITM refusal on DigitalOcean IP reuse.",
  "reason": "",
  "blockers": []
}
**close-report** for #458 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 458, "status": "success", "commits": [ "2cde70acf7e4a770bdc756a5680ce3a4f6650072" ], "changed_files": [ "STATUS.md", "app/helper/cmd/helper/wiring_prod.go", "internal/clan/adapter.go", "internal/clan/adapter_test.go" ], "tests": [ { "command": "nix develop .#go-ci --command go test ./internal/clan/", "exit_code": 0 }, { "command": "nix develop .#go-ci --command go vet ./app/helper/...", "exit_code": 0 } ], "criteria": { "Adapter.UnitActive checks host keys against the app-scoped own-VPS file, not ~/.ssh/known_hosts": "internal/clan/adapter.go: UnitActive appends `-o UserKnownHostsFile=<path>` when a.sshKnownHostsFile is set; wired to ownVPSKnownHostsPath() at founding's newClanAdapter in wiring_prod.go", "Adapter gains a known-hosts-file option mirroring WithSSHIdentityFile": "internal/clan/adapter.go: WithSSHKnownHostsFile(path) AdapterOption + sshKnownHostsFile field", "Option wired at founding's newClanAdapter (own-VPS) but NOT the standalone fleet-hardware face": "wiring_prod.go: newClanAdapter(identity, knownHosts) — clan port passes ownVPSKnownHostsPath(), newClanFace() passes \"\"", "UnitActive is testable (command-runner seam / argv assertion) — no prior coverage": "internal/clan/adapter.go: sshRun transport seam (default execSSH); internal/clan/adapter_test.go: TestUnitActive_PinsScopedKnownHostsFile asserts the flag present on the pinned face and absent on the bare face, TestUnitActive_TruthfulFalseVsTransportError proves the systemctl-word read still holds over the seam" }, "summary": "clan.Adapter.UnitActive now pins its ssh host-key check to the app-scoped own-VPS known-hosts file (via a new instance-scoped WithSSHKnownHostsFile + sshRun seam), wired only on founding's own-VPS face, ending the false MITM refusal on DigitalOcean IP reuse.", "reason": "", "blockers": [] } ``` </details>
ben closed this issue 2026-08-12 00:58:33 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#458
No description provided.