rented carrier: supply SSHes with the guest-trust key before the box is ever taught to trust it #692

Closed
opened 2026-08-23 05:48:38 +00:00 by matou-build-agent · 1 comment

Failure

Journey leg supply red on 20260823T054045Z (sig cdebd4257a3d):

founding: seed the fleet software onto the rented server: fleetwire: prepare the guest dirs: fleetwire: ssh: exit status 255 — root@209.38.18.27: Permission denied (publickey,keyboard-interactive).

The stand-up log (state/founding-state.json) shows connect succeeded ("connected to root@209.38.18.27 — the rented gateway is reachable") several stages before supply failed with a publickey refusal against the SAME host. Two different SSH identities are in play, and only one of them is ever authorized on the box.

Root cause

internal/founding/rentedpath.go's runRented:

  • connect (line ~160) uses o.rentedCarrier, wired in app/helper/cmd/helper/wiring_prod.go:471-477 with Identity: rentOperatorKeyDir()/id_ed25519 — the key DigitalOcean injected at provision. This is the box's ONLY trusted key at this point (fresh image, no takeover).
  • supply (rentedpath.go:200-208) calls o.guestSupply.Seed(ctx, ip, ownVPSSSHPort). guestSupply is a single shared instance wired in wiring_prod.go:512-517 with Identity: guestTrustDir()/id_ed25519 — a DIFFERENT, freshly-minted key (o.guestTrust.Ensure(ctx) at rentedpath.go:195, called just before supply).
  • The guest-trust public key is only ever pushed into the box's authorized_keys inside installRented (rentedpath.go:273, AuthorizedKeys: appendGuestTrust(facts.RootAuthorizedKeys, guestTrust)), which is the configure step — and configure runs strictly AFTER supply in this path (rentedpath.go's own leg-order comment at the top of the file: "supply — the fleet software, landed FIRST (before the configure)").

So the code mints the guest-trust key and immediately SSHes with it to a box that has never been told to trust it. The comment right above the mint call (rentedpath.go:190-194) claims the public half is "fed into the box's trust... before use", but that feed only happens in the LATER configure step — the comment describes the own-VPS path's shape (where install precedes supply and does the same appendGuestTrust), not this path's actual (flipped) order.

This ordering is not accidental slop I can just swap back: internal/founding/rentedpath_test.go has TestRentedJourney_SupplyRunsBeforeEnroll (line 245) that explicitly locks in supply-before-configure ("the box is already NixOS, so supply lands FIRST... before the VMMode configure") — reversing the order to fix the key-trust bug would break an intentional, tested invariant, and could reintroduce whatever original problem (unit-start-before-binary-exists?) motivated flipping it in the first place. Untangling that requires knowing why the order was chosen, which I can't verify from this checkout or a real droplet.

Suspected layer / fix directions

This needs the rented carrier's trust-bootstrap fixed, not the leg order. Two real options, either of which is a genuine design call rather than a mechanical edit:

  1. Mirror the DDR 0191 pattern already used for connect. WithRentedCarrier gives the rented path its OWN carrier instance keyed on the rent-operator identity, separate from WithOwnVPSCarrier's ambient one. supply needs the same treatment: a second GuestSupply-shaped instance (or an identity override on the existing one) keyed on the rent-operator identity for the rented path's initial supply call, with the shared guest-trust-keyed instance still used post-configure and for the private/own-VPS paths.
  2. Push the guest-trust public key onto the box directly, right after connect, over the rent-operator identity (a small explicit ssh ... >> /root/.ssh/authorized_keys step, reusing the line format appendGuestTrust already builds) — before supply runs at all.

Either also has a knock-on question worth checking while this is being designed: installRented (rentedpath.go:269) sets AmbientSSH: true on the configure clan.Enroll call, with a comment claiming this reaches the box "over the app's own key (the key DO injected at provision)" — but AmbientSSH: true makes clan.enrollment.identity() (internal/clan/enrollment.go:1131-1140) return "" (no -i at all), i.e. plain ssh-agent/default-key resolution. The rent-operator private key lives at the app's own state dir (rentOperatorKeyDir()), not in the operator's ambient ~/.ssh or agent, so configure looks like it would ALSO fail publickey once supply is fixed — it just hasn't been reached yet in this drive. Worth confirming/fixing in the same pass so the next rented drive doesn't just move the red leg from supply to configure.

Evidence

  • test-results/drive-rented/20260823T054045Z/artifacts/journey.rented-rented-gate-014d4--on-a-broker-rented-droplet/error-context.md — the JourneyFailure and page snapshot.
  • test-results/drive-rented/20260823T054045Z/state/founding-state.json — the standup.events log showing connect succeeding then supply failing against the same IP.
  • internal/founding/rentedpath.go:150-213 (leg order + the supply call), :190-198 (guest-trust mint + its now-inaccurate comment), :269-273 (AmbientSSH: true + appendGuestTrust in installRented).
  • app/helper/cmd/helper/wiring_prod.go:454-477 (rented carrier's own rent-operator identity) vs :512-517 (the single shared guest-trust-keyed guest-supply).
  • internal/founding/rentedpath_test.go:243-276 (TestRentedJourney_SupplyRunsBeforeEnroll, the invariant that rules out a simple reorder).
  • internal/clan/enrollment.go:1131-1140 (identity(): AmbientSSH → no -i at all).

drive 20260823T054045Z red at pair: journey leg "supply" went red: founding: seed the fleet software onto the rented server: fleetwire: prepare the guest dirs: fleetwire: ssh: exit status 255 — root@209.38.18.27: Permission denied (pu
evidence: test-results/…/20260823T054045Z/ on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596)

## Failure Journey leg `supply` red on `20260823T054045Z` (sig `cdebd4257a3d`): ``` founding: seed the fleet software onto the rented server: fleetwire: prepare the guest dirs: fleetwire: ssh: exit status 255 — root@209.38.18.27: Permission denied (publickey,keyboard-interactive). ``` The stand-up log (`state/founding-state.json`) shows `connect` **succeeded** ("connected to root@209.38.18.27 — the rented gateway is reachable") several stages before `supply` failed with a publickey refusal against the SAME host. Two different SSH identities are in play, and only one of them is ever authorized on the box. ## Root cause `internal/founding/rentedpath.go`'s `runRented`: - `connect` (line ~160) uses `o.rentedCarrier`, wired in `app/helper/cmd/helper/wiring_prod.go:471-477` with `Identity: rentOperatorKeyDir()/id_ed25519` — the key DigitalOcean injected at provision. This is the box's ONLY trusted key at this point (fresh image, no takeover). - `supply` (rentedpath.go:200-208) calls `o.guestSupply.Seed(ctx, ip, ownVPSSSHPort)`. `guestSupply` is a single shared instance wired in `wiring_prod.go:512-517` with `Identity: guestTrustDir()/id_ed25519` — a DIFFERENT, freshly-minted key (`o.guestTrust.Ensure(ctx)` at rentedpath.go:195, called just before supply). - The guest-trust public key is only ever pushed into the box's `authorized_keys` inside `installRented` (rentedpath.go:273, `AuthorizedKeys: appendGuestTrust(facts.RootAuthorizedKeys, guestTrust)`), which is the **`configure`** step — and `configure` runs strictly AFTER `supply` in this path (rentedpath.go's own leg-order comment at the top of the file: "supply — the fleet software, landed FIRST (before the configure)"). So the code mints the guest-trust key and immediately SSHes with it to a box that has never been told to trust it. The comment right above the mint call (rentedpath.go:190-194) claims the public half is "fed into the box's trust... before use", but that feed only happens in the LATER configure step — the comment describes the own-VPS path's shape (where `install` precedes `supply` and does the same `appendGuestTrust`), not this path's actual (flipped) order. This ordering is not accidental slop I can just swap back: `internal/founding/rentedpath_test.go` has `TestRentedJourney_SupplyRunsBeforeEnroll` (line 245) that explicitly locks in supply-before-configure ("the box is already NixOS, so supply lands FIRST... before the VMMode configure") — reversing the order to fix the key-trust bug would break an intentional, tested invariant, and could reintroduce whatever original problem (unit-start-before-binary-exists?) motivated flipping it in the first place. Untangling that requires knowing why the order was chosen, which I can't verify from this checkout or a real droplet. ## Suspected layer / fix directions This needs the rented carrier's trust-bootstrap fixed, not the leg order. Two real options, either of which is a genuine design call rather than a mechanical edit: 1. **Mirror the DDR 0191 pattern already used for `connect`.** `WithRentedCarrier` gives the rented path its OWN carrier instance keyed on the rent-operator identity, separate from `WithOwnVPSCarrier`'s ambient one. `supply` needs the same treatment: a second `GuestSupply`-shaped instance (or an identity override on the existing one) keyed on the rent-operator identity for the rented path's initial supply call, with the shared guest-trust-keyed instance still used post-configure and for the private/own-VPS paths. 2. **Push the guest-trust public key onto the box directly, right after `connect`, over the rent-operator identity** (a small explicit `ssh ... >> /root/.ssh/authorized_keys` step, reusing the line format `appendGuestTrust` already builds) — before `supply` runs at all. Either also has a knock-on question worth checking while this is being designed: `installRented` (rentedpath.go:269) sets `AmbientSSH: true` on the `configure` `clan.Enroll` call, with a comment claiming this reaches the box "over the app's own key (the key DO injected at provision)" — but `AmbientSSH: true` makes `clan.enrollment.identity()` (internal/clan/enrollment.go:1131-1140) return `""` (no `-i` at all), i.e. plain ssh-agent/default-key resolution. The rent-operator private key lives at the app's own state dir (`rentOperatorKeyDir()`), not in the operator's ambient `~/.ssh` or agent, so `configure` looks like it would ALSO fail publickey once `supply` is fixed — it just hasn't been reached yet in this drive. Worth confirming/fixing in the same pass so the next rented drive doesn't just move the red leg from `supply` to `configure`. ## Evidence - `test-results/drive-rented/20260823T054045Z/artifacts/journey.rented-rented-gate-014d4--on-a-broker-rented-droplet/error-context.md` — the JourneyFailure and page snapshot. - `test-results/drive-rented/20260823T054045Z/state/founding-state.json` — the `standup.events` log showing `connect` succeeding then `supply` failing against the same IP. - `internal/founding/rentedpath.go:150-213` (leg order + the supply call), `:190-198` (guest-trust mint + its now-inaccurate comment), `:269-273` (`AmbientSSH: true` + `appendGuestTrust` in `installRented`). - `app/helper/cmd/helper/wiring_prod.go:454-477` (rented carrier's own rent-operator identity) vs `:512-517` (the single shared guest-trust-keyed `guest-supply`). - `internal/founding/rentedpath_test.go:243-276` (`TestRentedJourney_SupplyRunsBeforeEnroll`, the invariant that rules out a simple reorder). - `internal/clan/enrollment.go:1131-1140` (`identity()`: `AmbientSSH` → no `-i` at all). drive `20260823T054045Z` red at `pair`: `journey leg "supply" went red: founding: seed the fleet software onto the rented server: fleetwire: prepare the guest dirs: fleetwire: ssh: exit status 255 — root@209.38.18.27: Permission denied (pu` evidence: `test-results/…/20260823T054045Z/` on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596) <!-- rehearsal-sig: cdebd4257a3d -->
Author
Member

Ruled by agent under ADR 0174 — veto anytime. This is a two-way door: revertible by commit, provable by unit test — a code fix to the rented carrier's leg-order/identity wiring, no personal credentials, no security-posture widening (if anything it tightens which identity a fresh box is dialled over), no member-facing trust accept, no data destruction. Ruling: fix landed, not routed to ready-for-human.

What landed (af942243):

  • Root cause confirmed as diagnosed: guestTrust.Ensure only mints the guest-trust keypair; the box isn't taught to trust its public half until the later configure step (installRented's appendGuestTrust), but the rented path lands supply before configure. The stale comment claiming the trust-feed already happened by supply time is fixed (it described the own-VPS shape, not this path's actual flipped order).
  • Fix direction 1 from the ticket, adapted: the rented path's initial supply now dials its own rent-operator-keyed seam (WithRentedSupply, a second fleetwire.Supply instance) instead of the shared guest-trust-keyed guestSupply — mirrors DDR 0191's carrier split exactly as suggested.
  • Also fixed the knock-on configure/AmbientSSH question the ticket flagged as unconfirmed-but-worth-checking: AmbientSSH: true resolved to the operator's ambient key/agent, which never holds the app-minted rent-operator key (it lives in the app's own state dir) — so configure would have gone red the same way the moment supply was fixed. Fixed by adding an explicit clan.EnrollRequest.Identity override (a third identity case AmbientSSH can't express), sourced from a new RentPubKey.IdentityFile() method. This required a small, additive change to internal/clan's EnrollRequest/enrollSnapshot — confirmed safe against the package's single-writer ConfigRepo invariant (no second Adapter/repo handle created; same shared adapter, per-call identity override only).
  • installRented's stale comments corrected to match reality throughout.

Proof: go build ./..., go vet ./..., gofmt -l . all clean. Full suite green (go test ./..., 56/56 packages, exit 0). New targeted tests: internal/clan.TestEnroll_ExplicitIdentityOverridesConfiguredIdentity; internal/founding's TestRentedJourney_SupplyDialsRentedSupplyNeverGuestSupply (proves supply now dials the rent-operator-keyed seam and never the guest-trust one, with two distinct fakes), TestRentedJourney_UnwiredRentedSupplyFailsLoud, TestRentedJourney_UnwiredRentPubKeyFailsLoud (ADR 0100 fail-loud guards), plus updated TestRentedJourney_RowsNeverIncludeInstallPhases/TestRentedJourney_SupplyRunsBeforeEnroll for the new identity shape.

Not proven: a real rented droplet — this checkout has none running (matching the same limitation the original diagnosis noted). Unit-test proof only, same evidentiary bar #691 closed on. The next rented rehearsal drive is the live proof; if it reds again the fix is one revert away.

docs/GOTCHAS.md #61 records the hazard class (minting an identity ≠ the target trusting it) so it doesn't recur elsewhere. STATUS.md updated in the same commit.

Closing — advances #692.

**Ruled by agent under ADR 0174 — veto anytime.** This is a two-way door: revertible by commit, provable by unit test — a code fix to the rented carrier's leg-order/identity wiring, no personal credentials, no security-posture widening (if anything it *tightens* which identity a fresh box is dialled over), no member-facing trust accept, no data destruction. Ruling: fix landed, not routed to `ready-for-human`. **What landed (`af942243`):** - Root cause confirmed as diagnosed: `guestTrust.Ensure` only *mints* the guest-trust keypair; the box isn't taught to trust its public half until the later `configure` step (`installRented`'s `appendGuestTrust`), but the rented path lands `supply` *before* `configure`. The stale comment claiming the trust-feed already happened by supply time is fixed (it described the own-VPS shape, not this path's actual flipped order). - Fix direction 1 from the ticket, adapted: the rented path's initial `supply` now dials its **own** rent-operator-keyed seam (`WithRentedSupply`, a second `fleetwire.Supply` instance) instead of the shared guest-trust-keyed `guestSupply` — mirrors DDR 0191's carrier split exactly as suggested. - Also fixed the knock-on `configure`/`AmbientSSH` question the ticket flagged as unconfirmed-but-worth-checking: `AmbientSSH: true` resolved to the *operator's* ambient key/agent, which never holds the app-minted rent-operator key (it lives in the app's own state dir) — so `configure` would have gone red the same way the moment `supply` was fixed. Fixed by adding an explicit `clan.EnrollRequest.Identity` override (a third identity case `AmbientSSH` can't express), sourced from a new `RentPubKey.IdentityFile()` method. This required a small, additive change to `internal/clan`'s `EnrollRequest`/`enrollSnapshot` — confirmed safe against the package's single-writer `ConfigRepo` invariant (no second `Adapter`/repo handle created; same shared adapter, per-call identity override only). - `installRented`'s stale comments corrected to match reality throughout. **Proof:** `go build ./...`, `go vet ./...`, `gofmt -l .` all clean. Full suite green (`go test ./...`, 56/56 packages, exit 0). New targeted tests: `internal/clan.TestEnroll_ExplicitIdentityOverridesConfiguredIdentity`; `internal/founding`'s `TestRentedJourney_SupplyDialsRentedSupplyNeverGuestSupply` (proves `supply` now dials the rent-operator-keyed seam and never the guest-trust one, with two distinct fakes), `TestRentedJourney_UnwiredRentedSupplyFailsLoud`, `TestRentedJourney_UnwiredRentPubKeyFailsLoud` (ADR 0100 fail-loud guards), plus updated `TestRentedJourney_RowsNeverIncludeInstallPhases`/`TestRentedJourney_SupplyRunsBeforeEnroll` for the new identity shape. **Not proven:** a real rented droplet — this checkout has none running (matching the same limitation the original diagnosis noted). Unit-test proof only, same evidentiary bar #691 closed on. The next rented rehearsal drive is the live proof; if it reds again the fix is one revert away. `docs/GOTCHAS.md` #61 records the hazard class (minting an identity ≠ the target trusting it) so it doesn't recur elsewhere. `STATUS.md` updated in the same commit. Closing — advances #692.
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#692
No description provided.