honest-error: GuestMeshJoin blames "setup key refused / netbird absent" for what is an ssh auth refusal (exit 255, publickey) #1202

Closed
opened 2026-09-03 21:13:09 +00:00 by matou-build-agent · 8 comments

Split from #1200 (found while fixing the enroll-trust mint gap; not the fault fixed there).

Symptom

internal/vm/manager.go (GuestMeshJoin, ~line 712) wraps EVERY failure of the guest netbird-mesh up SSH invocation with one fixed sentence:

vm: guest `netbird-mesh up` failed — the setup key was refused, or netbird is
absent from the guest image (ADR 0223): ssh [...]: exit status 255: ...
Permission denied (publickey,keyboard-interactive).

Why it's wrong

exit status 255 + Permission denied (publickey,...) is sshd rejecting the host agent before any command ran — the setup key was never presented and netbird was never reached. Naming "the setup key was refused, or netbird is absent" for an ssh AUTH refusal is a masked/mis-attributed cause (ADR 0100 asks for an honest per-stage sentence). #1200's real defect (no enroll-trust key minted) was hidden behind this line for the whole drive.

Note: with #1200's mint fix landed, this exact refusal should no longer occur on a healthy path — but the error text still mis-describes any future ssh-layer refusal (wrong key, wrong port, guest sshd down), so the honest-sentence fix stands on its own.

Suggested shape

Distinguish the ssh transport/auth failure (exit 255 / Permission denied / Connection refused) from a genuine netbird-mesh up command failure (a non-255 exit after ssh authenticated), and give each its own sentence. Reachable two-way (an error-classification + message change, revertible + contract-test-provable — the manager's ssh invocation is already asserted in the contract tests).

Advances #1153.

Split from #1200 (found while fixing the enroll-trust mint gap; not the fault fixed there). ## Symptom `internal/vm/manager.go` (`GuestMeshJoin`, ~line 712) wraps EVERY failure of the guest `netbird-mesh up` SSH invocation with one fixed sentence: ``` vm: guest `netbird-mesh up` failed — the setup key was refused, or netbird is absent from the guest image (ADR 0223): ssh [...]: exit status 255: ... Permission denied (publickey,keyboard-interactive). ``` ## Why it's wrong `exit status 255` + `Permission denied (publickey,...)` is **sshd rejecting the host agent before any command ran** — the setup key was never presented and `netbird` was never reached. Naming "the setup key was refused, or netbird is absent" for an ssh AUTH refusal is a masked/mis-attributed cause (ADR 0100 asks for an honest per-stage sentence). #1200's real defect (no enroll-trust key minted) was hidden behind this line for the whole drive. Note: with #1200's mint fix landed, this exact refusal should no longer occur on a healthy path — but the error text still mis-describes any future ssh-layer refusal (wrong key, wrong port, guest sshd down), so the honest-sentence fix stands on its own. ## Suggested shape Distinguish the ssh **transport/auth** failure (exit 255 / `Permission denied` / `Connection refused`) from a genuine `netbird-mesh up` **command** failure (a non-255 exit after ssh authenticated), and give each its own sentence. Reachable two-way (an error-classification + message change, revertible + contract-test-provable — the manager's ssh invocation is already asserted in the contract tests). Advances #1153.
Author
Member

This was generated by AI during triage.

Agent Brief

Category: bug
Summary: GuestMeshJoin wraps every failure of the guest netbird-mesh up SSH invocation with the single sentence "the setup key was refused, or netbird is absent from the guest image", even when the failure is an ssh transport/auth refusal (exit 255 / Permission denied / Connection refused) where no command ran and neither the setup key nor netbird was ever reached — a masked/mis-attributed cause (ADR 0100).

Current behavior:
The VM-mode land-time mesh join (Manager.GuestMeshJoin, ADR 0223) runs netbird-mesh up on the guest over ssh and wraps any error with one fixed message blaming a refused setup key or an absent netbird. When the ssh layer itself rejects the host agent (exit status 255 with Permission denied (publickey,...), or Connection refused), no command executed on the guest — so blaming the setup key or netbird is wrong. In drive 20260903T204213Z (#1200) this line hid the real defect (no enroll-trust key minted) for the whole drive.

Desired behavior:
Distinguish the two failure classes and give each its own honest sentence:

  • ssh transport/auth failure — exit status 255, or output containing Permission denied / Connection refused (host agent rejected before any command ran): the message describes an ssh transport/auth refusal (wrong key, wrong port, guest sshd down), not a setup-key or netbird problem.
  • command failure — ssh authenticated and netbird-mesh up ran but exited non-zero (a non-255 exit): the message may name the setup-key-refused / netbird-absent cause as before.
    The underlying error and trimmed guest output remain included in both cases.

Key interfaces:

  • Manager.GuestMeshJoin (in the vm manager) — classify the error returned by its ssh invocation of netbird-mesh up into transport/auth vs command failure, and emit the matching sentence. Classification should key off the ssh exit status (255) and/or the recognizable ssh refusal strings, not off netbird semantics.

Acceptance criteria:

  • An ssh failure surfaced as exit 255 / Permission denied produces a message describing an ssh transport/auth refusal and does not claim the setup key was refused or netbird is absent.
  • A Connection refused ssh failure is treated as the transport/auth class.
  • A genuine non-255 netbird-mesh up command failure (ssh authenticated, command exited non-zero) still produces the setup-key/netbird sentence.
  • The wrapped underlying error and trimmed guest output remain present in both messages.
  • The vm manager contract test that already asserts the ssh invocation is extended to cover both the auth-refusal message and the command-failure message.

Out of scope:

  • Fixing the enroll-trust key mint gap (done in #1200) — this ticket does not change join behavior, only the error classification and text.
  • Retrying or otherwise handling the ssh failure differently; this is purely about honest attribution.

Advances #1153. Ruled ready-for-agent (no ADR-0174 residue): an error-classification + message change, revertible by a later commit and provable by the existing vm-manager contract test — a two-way door with no one-way-door surface. Verified GuestMeshJoin and its fixed error line exist in the vm manager, and that internal/vm/manager_test.go already asserts the ssh invocation.

> *This was generated by AI during triage.* ## Agent Brief **Category:** bug **Summary:** `GuestMeshJoin` wraps *every* failure of the guest `netbird-mesh up` SSH invocation with the single sentence "the setup key was refused, or netbird is absent from the guest image", even when the failure is an ssh transport/auth refusal (exit 255 / `Permission denied` / `Connection refused`) where no command ran and neither the setup key nor netbird was ever reached — a masked/mis-attributed cause (ADR 0100). **Current behavior:** The VM-mode land-time mesh join (`Manager.GuestMeshJoin`, ADR 0223) runs `netbird-mesh up` on the guest over ssh and wraps any error with one fixed message blaming a refused setup key or an absent netbird. When the ssh layer itself rejects the host agent (exit status 255 with `Permission denied (publickey,...)`, or `Connection refused`), no command executed on the guest — so blaming the setup key or netbird is wrong. In drive `20260903T204213Z` (#1200) this line hid the real defect (no enroll-trust key minted) for the whole drive. **Desired behavior:** Distinguish the two failure classes and give each its own honest sentence: - **ssh transport/auth failure** — exit status 255, or output containing `Permission denied` / `Connection refused` (host agent rejected before any command ran): the message describes an ssh transport/auth refusal (wrong key, wrong port, guest sshd down), **not** a setup-key or netbird problem. - **command failure** — ssh authenticated and `netbird-mesh up` ran but exited non-zero (a non-255 exit): the message may name the setup-key-refused / netbird-absent cause as before. The underlying error and trimmed guest output remain included in both cases. **Key interfaces:** - `Manager.GuestMeshJoin` (in the vm manager) — classify the error returned by its ssh invocation of `netbird-mesh up` into transport/auth vs command failure, and emit the matching sentence. Classification should key off the ssh exit status (255) and/or the recognizable ssh refusal strings, not off netbird semantics. **Acceptance criteria:** - [ ] An ssh failure surfaced as exit 255 / `Permission denied` produces a message describing an ssh transport/auth refusal and does **not** claim the setup key was refused or netbird is absent. - [ ] A `Connection refused` ssh failure is treated as the transport/auth class. - [ ] A genuine non-255 `netbird-mesh up` command failure (ssh authenticated, command exited non-zero) still produces the setup-key/netbird sentence. - [ ] The wrapped underlying error and trimmed guest output remain present in both messages. - [ ] The vm manager contract test that already asserts the ssh invocation is extended to cover both the auth-refusal message and the command-failure message. **Out of scope:** - Fixing the enroll-trust key mint gap (done in #1200) — this ticket does not change join behavior, only the error classification and text. - Retrying or otherwise handling the ssh failure differently; this is purely about honest attribution. --- Advances #1153. Ruled `ready-for-agent` (no ADR-0174 residue): an error-classification + message change, revertible by a later commit and provable by the existing vm-manager contract test — a two-way door with no one-way-door surface. Verified `GuestMeshJoin` and its fixed error line exist in the vm manager, and that `internal/vm/manager_test.go` already asserts the ssh invocation.
Author
Member

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

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

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

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

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

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

swarm-claim host=elitebook-distributed-server-03 run=17398
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=17398 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=17402
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=17402 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

swarm-claim host=48e93cb2da61 run=17402
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=48e93cb2da61 run=17402 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #1202 — status success

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

envelope
{
  "issue": 1202,
  "status": "success",
  "commits": [
    "dd569b684422b7686cfa9661429d00abc0b5eef3"
  ],
  "changed_files": [
    "internal/vm/manager.go",
    "internal/vm/manager_test.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go test ./internal/vm/",
      "exit_code": 0
    },
    {
      "command": "pre-push gate: gofmt/build/vet/test/golangci-lint on main module + broker + dev tags",
      "exit_code": 0
    }
  ],
  "criteria": {
    "An ssh failure surfaced as exit 255 / Permission denied produces an ssh transport/auth message, not a setup-key/netbird claim": "internal/vm/manager.go isSSHTransportFailure branch in GuestMeshJoin; TestGuestMeshJoin_SSHAuthRefusalIsTransportNotSetupKey asserts no 'setup key was refused'/'netbird is absent' and presence of 'exit status 255'/'Permission denied'",
    "A Connection refused ssh failure is treated as the transport/auth class": "isSSHTransportFailure matches 'Connection refused'; TestGuestMeshJoin_ConnectionRefusedIsTransport asserts the transport sentence",
    "A genuine non-255 netbird-mesh up command failure still produces the setup-key/netbird sentence": "TestGuestMeshJoin_UpCommandFailureBlamesSetupKey (exit status 1) asserts 'setup key was refused' sentence",
    "The wrapped underlying error and trimmed guest output remain present in both messages": "both fmt.Errorf branches keep '%w: %s'; command-failure test asserts 'exit status 1' + guest output; transport test asserts 'exit status 255' + 'Permission denied'",
    "The vm manager contract test asserting the ssh invocation is extended to cover both messages": "internal/vm/manager_test.go: guestUpOut fake field + three GuestMeshJoin tests covering auth-refusal and command-failure messages"
  },
  "summary": "GuestMeshJoin now classifies an ssh transport/auth refusal (exit 255 / Permission denied / Connection refused) apart from a genuine netbird-mesh up command failure and gives each an honest sentence.",
  "blockers": []
}
**close-report** for #1202 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1202, "status": "success", "commits": [ "dd569b684422b7686cfa9661429d00abc0b5eef3" ], "changed_files": [ "internal/vm/manager.go", "internal/vm/manager_test.go" ], "tests": [ { "command": "nix develop .#go-ci -c go test ./internal/vm/", "exit_code": 0 }, { "command": "pre-push gate: gofmt/build/vet/test/golangci-lint on main module + broker + dev tags", "exit_code": 0 } ], "criteria": { "An ssh failure surfaced as exit 255 / Permission denied produces an ssh transport/auth message, not a setup-key/netbird claim": "internal/vm/manager.go isSSHTransportFailure branch in GuestMeshJoin; TestGuestMeshJoin_SSHAuthRefusalIsTransportNotSetupKey asserts no 'setup key was refused'/'netbird is absent' and presence of 'exit status 255'/'Permission denied'", "A Connection refused ssh failure is treated as the transport/auth class": "isSSHTransportFailure matches 'Connection refused'; TestGuestMeshJoin_ConnectionRefusedIsTransport asserts the transport sentence", "A genuine non-255 netbird-mesh up command failure still produces the setup-key/netbird sentence": "TestGuestMeshJoin_UpCommandFailureBlamesSetupKey (exit status 1) asserts 'setup key was refused' sentence", "The wrapped underlying error and trimmed guest output remain present in both messages": "both fmt.Errorf branches keep '%w: %s'; command-failure test asserts 'exit status 1' + guest output; transport test asserts 'exit status 255' + 'Permission denied'", "The vm manager contract test asserting the ssh invocation is extended to cover both messages": "internal/vm/manager_test.go: guestUpOut fake field + three GuestMeshJoin tests covering auth-refusal and command-failure messages" }, "summary": "GuestMeshJoin now classifies an ssh transport/auth refusal (exit 255 / Permission denied / Connection refused) apart from a genuine netbird-mesh up command failure and gives each an honest sentence.", "blockers": [] } ``` </details>
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.

Dependencies

No dependencies set.

Reference
Matou/idss#1202
No description provided.