Title: design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred · Issue #5697 · developing-today/code · GitHub
Open Graph Title: design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred · Issue #5697 · developing-today/code
X Title: design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred · Issue #5697 · developing-today/code
Description: design: 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 daemo...
Open Graph Description: design: 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 cove...
X Description: design: 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 ...
Opengraph URL: https://github.com/developing-today/code/issues/5697
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"design: bake the SSH recovery path into the fleet binary — orchestrate system ssh now, native russh deferred","articleBody":"design: bake the SSH recovery path into the fleet binary\n\nLinks: epic #5412 · laptop-agent design #5343\nDrew's end state: **no shell scripts, no Python scripts — just the fleet\nbinary.** This issue covers the *recovery* SSH path only (the daemon-down\nescape hatch). The everyday path's Python is the sibling item: the\n`fleet laptop-agent` client domain (see Ordering, below).\n\n## Context — the recovery path today (three of our files)\n\n`~/tools/laptop-ssh.sh` (the shim) delegates exec-style calls to the\nlaptop-agent, but shapes the agent cannot express fall back to real SSH.\nThe fallback classes, from the shim's own header:\n\n- `LAPTOP_SSH_REAL=1` (explicit escape hatch / daemon-down recovery)\n- no arguments (interactive session) or a **leading ssh option**\n (`-L/-R/-W/-N/-t/-p/-l/-i/-o …` — forwards and TTY allocation)\n- **stdin carrying data** for the remote command (sudo -S feeds,\n `cat > file` pushes) — the daemon has no stdin channel\n\nThe fallback is `~/tools/laptop-ssh-real.sh`, which `exec`s system ssh:\n\n```sh\nexec ssh \\\n -o \"ProxyCommand=python3 $HOME/tools/laptop-proxy-connect.py\" \\\n -o \"StrictHostKeyChecking=yes\" \\\n -o \"UserKnownHostsFile=$HOME/.ssh/known_hosts_laptop\" \\\n -o \"IdentitiesOnly=yes\" -i \"$HOME/.ssh/id_ed25519\" \\\n -o \"ConnectTimeout=60\" -o \"ConnectionAttempts=3\" \\\n -o \"ServerAliveInterval=15\" -o \"ServerAliveCountMax=8\" \\\n -o \"ControlMaster=auto\" -o \"ControlPath=$HOME/.ssh/cm-%r@%h:%p\" \\\n -o \"ControlPersist=3600\" \\\n \"user@100.99.113.103\" \"$@\"\n```\n\n…and `~/tools/laptop-proxy-connect.py` is the HTTP CONNECT relay to the\nruntime proxy (:3130), reading the proxy credential from `HTTPS_PROXY`\nand sending it only inside the CONNECT request (the #948 fix; the pinned\nhost key in `~/.ssh/known_hosts_laptop` is a single line:\n`100.99.113.103 ssh-ed25519 …`).\n\n## Findings — most of this is already in the binary\n\n1. **The ProxyCommand already exists as Rust.**\n `pkgs/fleet/crates/fleet-proxy/src/stdio.rs` is documented as\n *\"`fleet proxy connect --stdio` — the ProxyCommand relay:\n laptop-proxy-connect.py's job, fleet-shaped\"* — it opens the CONNECT\n tunnel (`tunnel.rs`: credential from `HTTPS_PROXY`, inside the\n request only, never argv, never logged) and splices stdin/stdout\n onto it. Defaults already line up with the SSH target:\n `client.rs` `run_connect` uses `config.target_host()` for `--host`\n (fleet-config `DEFAULT_TARGET_HOST = \"100.99.113.103\"`) and\n `args.port.unwrap_or(22)`. It is already SSH-tested the hard way:\n the hand-rolled pumps exist because `splice(2)` froze the SSH\n handshake mid-stream (#5431), and the no-join teardown is the #5518\n fix. So the Python file is replaceable **today** by\n `ProxyCommand=fleet proxy connect --stdio`.\n2. **The codebase is deliberately synchronous and small.**\n `fleet-proxy`'s dependency list is `fleet-registry`, `fleet-config`,\n `fleet-proxy-proto`, `serde`, `serde_json`, `libc` — no async\n runtime, no crypto stack. The workspace release profile is a size\n contract (design note §2: connect variant target ≤1.5 MiB, hard\n budget ≤2 MiB, `opt-level = \"z\"`, LTO, stripped). Any SSH-in-Rust\n route is measured against that contract.\n3. **System ssh is present and is an OS component**: `/usr/bin/ssh`,\n OpenSSH 9.6p1 on this sandbox; NixOS provides it on the laptop side\n of life too. It is platform — like the kernel and libc the binary\n already relies on — not one of *our* scripts.\n\n## Route (i): native Rust SSH via russh — what \"possible\" honestly means\n\nrussh is the mainstream async Rust SSH library (client + server;\ndownstream clients ship PTY sessions, forwarding and known_hosts\nchecking on it). Checked against *our exact uses* (docs.rs, 2026-11-04):\n\n| Our use | russh | Notes |\n|---|---|---|\n| exec with exit codes | ✅ | `channel_open_session` + exec; exit status arrives as a channel message; there is a maintained `client_exec_simple` example. |\n| 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. |\n| Key auth from the existing key file | ✅ | `load_secret_key` + `authenticate_publickey`; offering exactly one key is the `IdentitiesOnly=yes` equivalent. |\n| **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. |\n| 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). |\n| 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. |\n| 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. |\n| **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. |\n| 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. |\n\nPlus the build cost from Finding 2: russh pulls Tokio + a crypto\nbackend and a large transitive tree into a workspace whose connect\nvariant has a hard 2 MiB budget and a no-async design.\n\n**Verdict on (i):** possible — genuinely — for the exec/stdin classes,\nwhich are most recovery use. **Not** a drop-in for the full fallback\nsurface (interactive, forwards, arbitrary options, warm multiplexing)\nwithout reimplementing a meaningful slice of the OpenSSH *client*.\nThe recovery path is the worst place in the system for parity gaps:\nit is, by definition, the thing we reach for when the primary path is\nalready broken.\n\n## Route (ii): the binary orchestrates system ssh (recovery only)\n\nA new verb (proposed: `fleet proxy ssh -- [ssh args…]`, in the proxy\ndomain because it *is* stdio + tunnel config) that:\n\n- builds exactly the argv `laptop-ssh-real.sh` builds today, except\n `ProxyCommand=\u003cthis exe> proxy connect --stdio` (path via\n `std::env::current_exe` — the pattern `client.rs`'s `spawn_serve`\n already uses), with the same pinned `UserKnownHostsFile`, key,\n timeouts, ServerAlive and ControlMaster settings, target\n `user@` + `config.target_host()`;\n- then **`exec()`s ssh** (process replacement, as the shell script's\n `exec` does): stdin/stdout/stderr, TTY, signals and exit code are\n OpenSSH's own, untouched — including every fallback class, by\n construction, and arbitrary user `-o` args pass through after ours.\n\nWhat it buys: the entire #948-hardened, battle-tested-since-2026-10-26\nsemantics with zero reimplementation; warm ControlMaster included.\nWhat it costs: a runtime dependency on an external `ssh` binary.\n\nIs that within the spirit of Drew's end state? **Yes.** The end state\nnames *our* shell scripts and *our* Python scripts. Route (ii) deletes\nall three from the path (`laptop-ssh-real.sh`, the Python ProxyCommand,\nand — with the sibling item — the shim itself). OpenSSH is an OS\ncomponent shipped and maintained with the platform, in the same\ncategory as the kernel, libc and the `setsid` the binary already calls.\n\"No external process at all\" is a stronger requirement than the one\nstated, and route (i) shows its price.\n\nOne honest caveat: recovery would depend on `fleet proxy connect\n--stdio` working. That dependency already exists in substance — the\nCONNECT relay is the only road to the laptop — and the Rust relay is\nsmaller, frozen-er and better tested (#5431, #5518) than the Python it\nreplaces. Document the manual last-resort (system ssh with a hand-typed\nCONNECT ProxyCommand, from this issue) in the runbook, not as a script\non PATH.\n\n## Recommendation — hybrid, staged\n\n1. **Now: route (ii).** Implement `fleet proxy ssh` orchestrating system\n ssh with self-ProxyCommand. This achieves the stated end state for\n the recovery path in one small, low-risk step.\n2. **Deferred: route (i), exec-only scope**, as an optional native mode\n of the same verb, triggered only by: a target host with no OpenSSH\n client, a concrete route-(ii) failure attributable to OpenSSH, or an\n explicit future requirement of zero external processes for a specific\n deployment. If built, its scope is exec/stdin/exit-code + pinned-key\n verification via `check_known_hosts_path`; interactive and forwards\n stay on system ssh until parity is *proven*, not asserted.\n\n## Ordering dependency\n\nThe `laptop-agent` client domain in the binary is still a stub:\nin `pkgs/fleet/crates/fleet/src/main.rs` the domain falls through to\nthe capability stub (exit 69) for real verbs, and the shim's header says\nits delegate flips from `~/tools/laptop-agent.py` to\n`fleet laptop-agent` when that domain lands. Sequence:\n\n1. `fleet laptop-agent` client domain lands → removes the **everyday**\n Python (`laptop-agent.py`).\n2. This item's `fleet proxy ssh` lands → removes the **recovery**\n shell + Python (`laptop-ssh-real.sh`, `laptop-proxy-connect.py`).\n3. Only then can `laptop-ssh.sh` itself be deleted: its exec classes\n point at (1), its fallback classes at (2). Doing (2) first is fine;\n deleting the shim before both exist is not.\n\n## Next steps\n\n1. Implement `fleet proxy ssh` per route (ii): fixed option block\n mirroring `laptop-ssh-real.sh`, self-ProxyCommand, argv passthrough,\n `HTTPS_PROXY`-unset error identical to today's.\n2. Parity tests before any cutover: wrong-host-key negative test\n (#948), stdin-data test (sudo -S shape), `bash -s` script test,\n interactive `-t` smoke, `-L` forward smoke, second-call warm\n ControlMaster timing.\n3. Flip the shim's fallback `exec` to the new verb; soak; then retire\n `laptop-ssh-real.sh` and `laptop-proxy-connect.py`.\n4. Keep the russh evaluation above as the starting point if a stage-2\n trigger ever fires — do not re-litigate from scratch.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-11-04T23:13:32Z","url":"https://github.com/developing-today/code/issues/5697"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e4511a1e-688f-85d4-ec0c-a429496a5bcb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EDA6:2E0249:9B8EF7:C9F9D1:6B063422 |
| html-safe-nonce | 790256feb4b61413166bcafdcd9c63d693977e4d1188edca23b185d7ea9c9a8b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFREE2OjJFMDI0OTo5QjhFRjc6QzlGOUQxOjZCMDYzNDIyIiwidmlzaXRvcl9pZCI6IjU1NzE5NjE3MTQ1NzAwNDg1NDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4f727b9c75d4c74746e04aa31ffb8f72288f080c00170af101a0abb0248b3f8f |
| hovercard-subject-tag | issue:6213206722 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/5697/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a1ec2993131a65384ad2e07c99aa81c55fb576052e03a0d66849a81b518614f0/developing-today/code/issues/5697 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a1ec2993131a65384ad2e07c99aa81c55fb576052e03a0d66849a81b518614f0/developing-today/code/issues/5697 |
| og:image:alt | design: 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 cove... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | c3584c853cd39700ecff6e2cf8364295ffdb5313e571046c41cd2479270f7df0 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9eb3bb1597d09170a5f282cd38ae376dee1a5ec1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width