GeezerVison is showing github.com — design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred · Issue #5697 · developing-today/code
design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred #5697Descriptiondesign: bake the SSH recovery path into the fleet binary
Links: epic #5412 · laptop-agent design #5343
Drew's end state: no shell scripts, no Python scripts — just the fleet
binary. This issue covers the recovery SSH path only (the daemon-down
escape hatch). The everyday path's Python is the sibling item: the
fleet laptop-agent client domain (see Ordering, below).
Context — the recovery path today (three of our files)
~/tools/laptop-ssh.sh (the shim) delegates exec-style calls to the
laptop-agent, but shapes the agent cannot express fall back to real SSH.
The fallback classes, from the shim's own header:
LAPTOP_SSH_REAL=1 (explicit escape hatch / daemon-down recovery)
- no arguments (interactive session) or a leading ssh option
(-L/-R/-W/-N/-t/-p/-l/-i/-o … — forwards and TTY allocation)
- stdin carrying data for the remote command (sudo -S feeds,
cat > file pushes) — the daemon has no stdin channel
The fallback is ~/tools/laptop-ssh-real.sh, which execs system ssh:
exec ssh \
-o "ProxyCommand=python3 $HOME/tools/laptop-proxy-connect.py" \
-o "StrictHostKeyChecking=yes" \
-o "UserKnownHostsFile=$HOME/.ssh/known_hosts_laptop" \
-o "IdentitiesOnly=yes" -i "$HOME/.ssh/id_ed25519" \
-o "ConnectTimeout=60" -o "ConnectionAttempts=3" \
-o "ServerAliveInterval=15" -o "ServerAliveCountMax=8" \
-o "ControlMaster=auto" -o "ControlPath=$HOME/.ssh/cm-%r@%h:%p" \
-o "ControlPersist=3600" \
"[email protected]" "$@"
…and ~/tools/laptop-proxy-connect.py is the HTTP CONNECT relay to the
runtime proxy (:3130), reading the proxy credential from HTTPS_PROXY
and sending it only inside the CONNECT request (the #948 fix; the pinned
host key in ~/.ssh/known_hosts_laptop is a single line:
100.99.113.103 ssh-ed25519 …).
Findings — most of this is already in the binary
- The ProxyCommand already exists as Rust.
pkgs/fleet/crates/fleet-proxy/src/stdio.rs is documented as
"fleet proxy connect --stdio — the ProxyCommand relay:
laptop-proxy-connect.py's job, fleet-shaped" — it opens the CONNECT
tunnel (tunnel.rs: credential from HTTPS_PROXY, inside the
request only, never argv, never logged) and splices stdin/stdout
onto it. Defaults already line up with the SSH target:
client.rs run_connect uses config.target_host() for --host
(fleet-config DEFAULT_TARGET_HOST = "100.99.113.103") and
args.port.unwrap_or(22). It is already SSH-tested the hard way:
the hand-rolled pumps exist because splice(2) froze the SSH
handshake mid-stream (fleet step 3: proxy domains — hello/capability frame, PATH shim regeneration, fleet init #5431), and the no-join teardown is the fleet-proxy(stdio): relay never exits after remote close while stdin stays open — up.join() waits on a stdin-blocked thread #5518
fix. So the Python file is replaceable today by
ProxyCommand=fleet proxy connect --stdio.
- The codebase is deliberately synchronous and small.
fleet-proxy's dependency list is fleet-registry, fleet-config,
fleet-proxy-proto, serde, serde_json, libc — no async
runtime, no crypto stack. The workspace release profile is a size
contract (design note §2: connect variant target ≤1.5 MiB, hard
budget ≤2 MiB, opt-level = "z", LTO, stripped). Any SSH-in-Rust
route is measured against that contract.
- System ssh is present and is an OS component:
/usr/bin/ssh,
OpenSSH 9.6p1 on this sandbox; NixOS provides it on the laptop side
of life too. It is platform — like the kernel and libc the binary
already relies on — not one of our scripts.
Route (i): native Rust SSH via russh — what "possible" honestly means
russh is the mainstream async Rust SSH library (client + server;
downstream clients ship PTY sessions, forwarding and known_hosts
checking on it). Checked against our exact uses (docs.rs, 2026-11-04):
| Our use |
russh |
Notes |
| exec with exit codes |
✅ |
channel_open_session + exec; exit status arrives as a channel message; there is a maintained client_exec_simple example. |
stdin-script mode (bash -s, python3 -) |
✅ |
A channel is a byte stream: write the script, send EOF. Unlike the agent daemon, SSH has a stdin channel — so the stdin-data class (sudo -S, cat > file) is equally expressible. ✅ for that too. |
| Key auth from the existing key file |
✅ |
load_secret_key + authenticate_publickey; offering exactly one key is the IdentitiesOnly=yes equivalent. |
| Host-key pinning |
✅ — best fit of all |
Handler::check_server_key is mandatory (default rejects), and russh::keys::known_hosts::check_known_hosts_path(path, …) verifies against a nonstandard file path — i.e. our existing pinned ~/.ssh/known_hosts_laptop with exactly one ed25519 key, no TOFU UX needed. |
| Transport over our tunnel |
⚠️ workable |
client::connect_stream runs over any AsyncRead+AsyncWrite stream — but tunnel.rs returns a sync std::net::TcpStream; bridging means adding a Tokio runtime island to a sync codebase (or re-implementing the CONNECT handshake in Tokio). |
| Port forwards |
⚠️ primitives only |
direct-tcpip (local), tcpip_forward (remote), streamlocal exist as protocol primitives. OpenSSH-grade -L/-R listener behaviour is app work; -D has no SOCKS server in russh — hand-rolled. |
| Interactive TTY |
⚠️ primitives only |
request_pty exists and there is an interactive-PTY example — but raw terminal mode, SIGWINCH → window-change, signal forwarding and escape handling are all ours to build and get subtly wrong. |
| ControlMaster / ControlPersist |
❌ |
No equivalent. Every invocation pays full CONNECT + SSH handshake + auth over the DERP path (seconds; new-connection setups have measured 5–45 s on this route) instead of riding the warm master (~0.4 s) the current script's ControlPersist=3600 gives us. Rebuilding it means a session-holding daemon — i.e. reinventing the broker, for the recovery path. |
| Arbitrary leading ssh options |
❌ |
The fallback contract is "pass -o/-p/-l/-i… through". russh has no ssh_config/CLI-option compatibility layer; we'd parse and translate a subset and silently diverge on the rest. |
Plus the build cost from Finding 2: russh pulls Tokio + a crypto
backend and a large transitive tree into a workspace whose connect
variant has a hard 2 MiB budget and a no-async design.
Verdict on (i): possible — genuinely — for the exec/stdin classes,
which are most recovery use. Not a drop-in for the full fallback
surface (interactive, forwards, arbitrary options, warm multiplexing)
without reimplementing a meaningful slice of the OpenSSH client.
The recovery path is the worst place in the system for parity gaps:
it is, by definition, the thing we reach for when the primary path is
already broken.
Route (ii): the binary orchestrates system ssh (recovery only)
A new verb (proposed: fleet proxy ssh -- [ssh args…], in the proxy
domain because it is stdio + tunnel config) that:
- builds exactly the argv
laptop-ssh-real.sh builds today, except
ProxyCommand=<this exe> proxy connect --stdio (path via
std::env::current_exe — the pattern client.rs's spawn_serve
already uses), with the same pinned UserKnownHostsFile, key,
timeouts, ServerAlive and ControlMaster settings, target
user@ + config.target_host();
- then
exec()s ssh (process replacement, as the shell script's
exec does): stdin/stdout/stderr, TTY, signals and exit code are
OpenSSH's own, untouched — including every fallback class, by
construction, and arbitrary user -o args pass through after ours.
What it buys: the entire #948-hardened, battle-tested-since-2026-10-26
semantics with zero reimplementation; warm ControlMaster included.
What it costs: a runtime dependency on an external ssh binary.
Is that within the spirit of Drew's end state? Yes. The end state
names our shell scripts and our Python scripts. Route (ii) deletes
all three from the path (laptop-ssh-real.sh, the Python ProxyCommand,
and — with the sibling item — the shim itself). OpenSSH is an OS
component shipped and maintained with the platform, in the same
category as the kernel, libc and the setsid the binary already calls.
"No external process at all" is a stronger requirement than the one
stated, and route (i) shows its price.
One honest caveat: recovery would depend on fleet proxy connect --stdio working. That dependency already exists in substance — the
CONNECT relay is the only road to the laptop — and the Rust relay is
smaller, frozen-er and better tested (#5431, #5518) than the Python it
replaces. Document the manual last-resort (system ssh with a hand-typed
CONNECT ProxyCommand, from this issue) in the runbook, not as a script
on PATH.
Recommendation — hybrid, staged
- Now: route (ii). Implement
fleet proxy ssh orchestrating system
ssh with self-ProxyCommand. This achieves the stated end state for
the recovery path in one small, low-risk step.
- Deferred: route (i), exec-only scope, as an optional native mode
of the same verb, triggered only by: a target host with no OpenSSH
client, a concrete route-(ii) failure attributable to OpenSSH, or an
explicit future requirement of zero external processes for a specific
deployment. If built, its scope is exec/stdin/exit-code + pinned-key
verification via check_known_hosts_path; interactive and forwards
stay on system ssh until parity is proven, not asserted.
Ordering dependency
The laptop-agent client domain in the binary is still a stub:
in pkgs/fleet/crates/fleet/src/main.rs the domain falls through to
the capability stub (exit 69) for real verbs, and the shim's header says
its delegate flips from ~/tools/laptop-agent.py to
fleet laptop-agent when that domain lands. Sequence:
fleet laptop-agent client domain lands → removes the everyday
Python (laptop-agent.py).
- This item's
fleet proxy ssh lands → removes the recovery
shell + Python (laptop-ssh-real.sh, laptop-proxy-connect.py).
- Only then can
laptop-ssh.sh itself be deleted: its exec classes
point at (1), its fallback classes at (2). Doing (2) first is fine;
deleting the shim before both exist is not.
Next steps
- Implement
fleet proxy ssh per route (ii): fixed option block
mirroring laptop-ssh-real.sh, self-ProxyCommand, argv passthrough,
HTTPS_PROXY-unset error identical to today's.
- Parity tests before any cutover: wrong-host-key negative test
(security(aggregator): fleet-feed push exposes the proxy credential in process argv and disables SSH host-key verification #948), stdin-data test (sudo -S shape), bash -s script test,
interactive -t smoke, -L forward smoke, second-call warm
ControlMaster timing.
- Flip the shim's fallback
exec to the new verb; soak; then retire
laptop-ssh-real.sh and laptop-proxy-connect.py.
- Keep the russh evaluation above as the starting point if a stage-2
trigger ever fires — do not re-litigate from scratch.
Activitydezren39 commented on Nov 5, 2026 🤖 Agent note · handed off
dezren39 commented on Nov 5, 2026 🤖 Agent note · handed off
- Agent: queue worker (repo-worker-code), lane code-y
- Session / ID: task 10134
- Found via: queue claim
- Task: Triage of issue design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred #5697 (design: bake the SSH recovery path into the fleet binary) was claimed by lane code-y; the execution-lane assignment routed it to the opencode lane, so it is handed off — the laptop claimant (opencode-claimant) launches the bound opencode session that drives task 10134 to its terminal state.
- Expectation: claimant binds a session to task 10134; triage per the task packet.
- Links: task 10134 (queue repo-health-code-pilot)
developing-today commented on Nov 5, 2026 agent-note:v1
task: 10134
lane: code-u
state: handed-off
summary: Task 10134 claimed by lane code-u; execution-lane assignment returned opencode, so this task is handed off to the opencode claimant per the worker runbook §1b. Issue #5697 is OPEN with no hard-stop labels on fresh check; stale queue/parked + status/parked labels were replaced with queue/claimed + status/in-progress on claim (via the developing.today GitHub App route after the user token hit its rate limit).
next: opencode-claimant launches the bound opencode session for task 10134. dezren39 commented on Nov 5, 2026 🤖 Agent note · handed off
dezren39 commented on Nov 14, 2026
🤖 Agent note · already done (blocker disposition for task 12994)
- Agent: repo queue worker (repo-worker-code), Muse lane code-d
- Session / ID: task 16844 (triage follow-on of task 15277; blocker-not-queued cleanup pass 3 — "design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred #5697 blocks task 12994 / fleet: built-in fallback connection mode (direct/SSH) when the proxy path is unavailable — replaces laptop-ssh.sh family (docs migration stay-item R1) #5972")
- Disposition, verified fresh 2026-11-14: there is no unfinished design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred #5697 design work for anything to wait on. The design's "now" deliverable — route (ii),
fleet proxy ssh orchestrating system ssh with self-ProxyCommand — landed in PR feat(fleet): add proxy ssh recovery verb #6403, MERGED 2026-11-08T06:16:04Z (merge commit 1cc3526, re-verified via gh this shift). Native russh stays deferred exactly as this issue designs.
- Remainder owner: the shim cutover / soak / retirement of
laptop-ssh-real.sh + laptop-proxy-connect.py is fleet: built-in fallback connection mode (direct/SSH) when the proxy path is unavailable — replaces laptop-ssh.sh family (docs migration stay-item R1) #5972's own scope (OPEN, verified this shift). That is work inside task 12994's issue, not work design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred #5697 still owes it: any dependency of task 12994 recorded against design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred #5697's design is satisfied by PR feat(fleet): add proxy ssh recovery verb #6403, and what remains is fleet: built-in fallback connection mode (direct/SSH) when the proxy path is unavailable — replaces laptop-ssh.sh family (docs migration stay-item R1) #5972's soak gate, which is elapsed proof time, not a design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred #5697 deliverable.
user/review reviewed here: nothing in this remainder is a Drew decision (agreeing with task 13026's note). design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred #5697 stays OPEN as the design's home under user/review, per task 12262's terminal reasoning — it can close under Drew's review once fleet: built-in fallback connection mode (direct/SSH) when the proxy path is unavailable — replaces laptop-ssh.sh family (docs migration stay-item R1) #5972 closes; it should not gate task 12994 meanwhile.
- No new packet enqueued: one would duplicate fleet: built-in fallback connection mode (direct/SSH) when the proxy path is unavailable — replaces laptop-ssh.sh family (docs migration stay-item R1) #5972 (the same conclusion as tasks 12262, 13026, and 15277). Task 16844 completes as
already_done with PR feat(fleet): add proxy ssh recovery verb #6403 as evidence.
- Links: task 16844 · task 15277 · task 12994 · issue design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred #5697 · issue fleet: built-in fallback connection mode (direct/SSH) when the proxy path is unavailable — replaces laptop-ssh.sh family (docs migration stay-item R1) #5972 · PR feat(fleet): add proxy ssh recovery verb #6403
dezren39 commented on Nov 17, 2026 🤖 Agent note · done
Fresh re-verification (2026-11-17T03:20Z)
dezren39 commented on Nov 17, 2026 🤖 Agent note · triage — task 19881
- State: bulk-intake re-triage of design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred #5697, completed as triaged, concurring with the triage of record (task 15277, 2026-11-14; blocker disposition task 16844; concurrence task 18351, 2026-11-17T03:20Z). The
user/review label was reviewed first by this lane per its meaning: nothing in the remainder is a new Drew decision.
- Fresh re-verification (2026-11-17, this run): the design's "now" deliverable is present on current main (
4484882cdb): fleet proxy ssh dispatches in pkgs/fleet/crates/fleet/src/main.rs (:1070, build_proxy_ssh_argv :1161), landed by PR feat(fleet): add proxy ssh recovery verb #6403 (merged 2026-11-08, merge commit 1cc3526) with follow-up fixes for clustered ssh options and Fleet-home path resolution. On the laptop, ~/tools/laptop-ssh.sh, laptop-ssh-real.sh, and laptop-proxy-connect.py no longer exist — the recovery path the design targeted is gone from the laptop's tools.
- Remainder: owned by fleet: built-in fallback connection mode (direct/SSH) when the proxy path is unavailable — replaces laptop-ssh.sh family (docs migration stay-item R1) #5972 (OPEN, verified this run; now tracked as documentation/design/docs-migration). No follow-on packet enqueued — one would duplicate fleet: built-in fallback connection mode (direct/SSH) when the proxy path is unavailable — replaces laptop-ssh.sh family (docs migration stay-item R1) #5972, the same conclusion as tasks 12262, 13026, 15277, 16844, and 18351.
- Issue disposition: design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred #5697 stays OPEN as the design's home under
user/review; per the standing reasoning it can close under Drew's review once fleet: built-in fallback connection mode (direct/SSH) when the proxy path is unavailable — replaces laptop-ssh.sh family (docs migration stay-item R1) #5972 closes. Native russh remains deferred exactly as designed.
dezren39 commented on Nov 22, 2026
Lane Y (queue task 12994, via #5972) auditing the current fleet binary against this design: does fleet proxy ssh (route ii) or an equivalent exist today, and what does the proxy-down drill show? Findings will land here and on #5972. dezren39 commented on Nov 22, 2026
Lane Y — status against this design (via queue task 12994 / #5972)
Route (ii) has landed and is drill-verified. PR #6403 (merged 1cc3526cb, 2026-11-08) implemented fleet proxy ssh as specified here: pinned option block mirroring laptop-ssh-real.sh, self-ProxyCommand via current_exe (fleet proxy connect --stdio, the Rust CONNECT relay), argv passthrough after --, exec() of system ssh. Present in the sandbox recovery build and the laptop's deployed fleet. The full evidence record — including the live parity items from this issue's step 2 — is on #5972 (closed on that evidence):
- wrong-host-key negative test: live pass (bogus pin refused,
REMOTE HOST IDENTIFICATION HAS CHANGED)
- stdin-data (
cat pipe) and bash -s script tests: live pass
- interactive
-t smoke: option passes through; -tt allocates (/dev/pts/4 on the laptop)
-L forward smoke: live pass (HTTP 200 through the forward, served by the persisted ControlMaster)
- second-call warm ControlMaster timing: 1607 ms cold → 397 ms warm
- proxy-down axis: with the platform egress proxy dead/down (its actual post-restart state), the verb still reaches the laptop via tailscaled's local CONNECT proxy; with the local tailnet proxy itself unreachable the verb fails fast (12 ms) — direct TCP from this seat is sandbox-blocked, so the CONNECT relay remains the only road, as this issue's caveat already states
What remains of this issue:
- Step 3 of the Next steps — not done. The shim's fallback
exec still points at laptop-ssh-real.sh (Python ProxyCommand). Flip it to fleet proxy ssh -- "$@", soak, then retire laptop-ssh-real.sh and laptop-proxy-connect.py. Deliberately not done by this lane: the flip wants its soak while other work is mid-flight on the shim.
- Ordering step 1 — still open. The binary's
laptop-agent client domain is still the registry stub ("implementation lands in a later step of epic epic: one fleet multicall binary — search, queue, dispatch, proxy — with capability-selected builds #5412"); the everyday path still runs laptop-agent.py. Per the ordering recorded here, the shim itself is deleted only after both (1) and this land.
- Route (i) / russh — deferred, triggers unchanged; the evaluation above stands as the starting point.
Two seat-state repairs the drill needed are recorded on #5972 (restored known_hosts_laptop pin; sandbox key authorized on the laptop) — recovery leftovers, not defects in the verb. dezren39 commented on Nov 23, 2026
Lane felix — done-check verification record (shortlist draw, 2026-11-23)
Claimed and completed as a done check only: this issue's design already
landed and its "now" route is implemented and drill-verified, so no new
design document was written — one would duplicate this issue's own body,
which is the design record. Fresh verification against current main
(a77026ed0, 2026-11-23 16:01 CST) and this seat:
Design → implementation, confirmed on main. Route (ii) as designed:
fleet proxy ssh dispatches in pkgs/fleet/crates/fleet/src/main.rs
(run_proxy_ssh, build_proxy_ssh_argv): fixed option block mirroring
the retired script (StrictHostKeyChecking=yes, pinned
~/.ssh/known_hosts_laptop, IdentitiesOnly + ~/.ssh/id_ed25519,
ConnectTimeout=60, ConnectionAttempts=3, ServerAlive 15/8,
ControlMaster=auto + ControlPersist=3600), ProxyCommand=<current_exe> proxy connect --stdio (the Rust CONNECT relay — the Python relay's job),
caller ssh args passed through after the fixed block, and exec() of
system ssh. Landed by PR #6403 (merged 2026-11-08).
Drill evidence stands. The parity suite from this issue's step 2 was
run live and recorded on #5972 (wrong-host-key negative, stdin-data,
bash -s, -t, -L forward, ControlMaster 1607 ms cold → 397 ms warm,
proxy-down axis), and #5972 closed on that evidence 2026-11-22.
State has advanced past the last note on this issue (Lane Y,
2026-11-22, "step 3 not done"). On this seat, the step-3 cutover has
since happened: ~/tools/laptop-ssh.sh's header records the code#5972
step-3 cutover (2026-11-22) — its fallback classes (LAPTOP_SSH_REAL=1,
no-args/interactive, leading ssh option, stdin-data) now
exec "$HOME/tools/fleet" proxy ssh -- "$@", and laptop-ssh-real.sh
is no longer invoked by the shim. The ordering dependency's step 1 has
also advanced in source: the laptop-agent domain on main now
dispatches to fleet_laptop_agent::cli::run under the laptop-agent
feature (#10796), where this design recorded an exit-69 stub.
What actually remains — none of it belongs to this design:
- Retirement of
laptop-ssh-real.sh + laptop-proxy-connect.py on
this seat (the laptop's copies are already gone). The real script
stays on disk for one named reason in the shim's header:
laptop-agent.py's own SSH fallback transport still execs it. That
unblocks when the everyday path flips from laptop-agent.py to the
binary's now-landed laptop-agent domain — epic epic: one fleet multicall binary — search, queue, dispatch, proxy — with capability-selected builds #5412 / fleet binary: implement the laptop-agent domain — automatic transport fallback (CF → Tailscale → SSH) + CF Access credential from fleet secrets; retire the Python client's routing #10796
line, a deployment step, not a design gap here. The shim itself is
deleted after that, per this issue's ordering.
- Route (i) / russh — deferred exactly as designed; triggers
unchanged (a target host with no OpenSSH client, a concrete
route-(ii) failure attributable to OpenSSH, or an explicit
zero-external-process requirement). The evaluation in this issue
stands as the starting point.
Disposition: the recorded close condition — "close under Drew's
review once #5972 closes" — is now met (#5972 closed 2026-11-22). The
issue carries user/review, so the close is Drew's call; left open for
that review. One scoping note for the queue: questions about baking
leg auto-recovery (detecting dead tailscaled/broker legs and
restarting them from inside the binary, vs the seat's external
keeper/ensure scripts) are not this issue's scope — its
"detection" is the fallback-class routing above — and no design or
issue covers that question today; it would be a new item if wanted. dezren39 commented on Nov 24, 2026 Closing on Drewry's decision (2026-11-24).
Verified done: the design is this issue's body; the implementation (fleet proxy ssh) landed via PR #6403, the parity drill passed, #5972 closed 2026-11-22, and this seat's shim is flipped to the binary. Verification record: comment 7115293076 on this issue. The recorded close condition is met.
Noted separately (not part of this issue): nothing yet covers the fleet binary itself detecting/restarting dead tailscaled/broker legs — today that is Felix's external keeper script. File as a new item if wanted. dezren39 commented on Nov 24, 2026 Program tending (2026-11-24) — roadmap drift flagged, not edited: this issue closed COMPLETED today (2026-11-24T06:07Z), but planning/roadmaps/fleet.md still lists "The SSH recovery path in the binary" as shaped, linking only this issue.
Whether the shaped row's work is what this issue delivered, or a follow-on the row still intends, is not determinable from the row — so the row is left for its owner rather than edited on a guess. Labelled meta/roadmap-drift.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|