Monorepo for the nibling.run platform

SSH into an open sandbox tab through a stateless gateway (D25) #3

Merged nibling.dev
targeting main from nmoo/ssh/gateway
Merged opened by nibling.dev
targeting main from nmoo/ssh/gateway

ssh <handle>@ssh.nibling.dev lists the account's open sandboxes, ssh -t <handle>@ssh.nibling.dev <slug> opens a shell in one, and ssh <handle>@ssh.nibling.dev <slug> -- npm test runs one command and returns its exit code. This records D25 on main and ships everything it needs.

What lands #

  • packages/ssh-gateway: a self-hostable Node service on ssh2 and ws. SSH keys come from the account's org.tangled.key.sshKey records (legacy sh.tangled.publicKey as a fallback), cached an hour. A tab attaches over a WebSocket at /xrpc/dev.nibling.ssh.attach with a 60-second service-auth token whose audience is did:web:<gateway host>, verified against the account's signing key. Channels are a small state machine with explicit EOF both ways and a 64 MB buffer cap. Git verbs are parsed and answered with pkt-line errors, and routing them to a tab stays behind --git until the git remote work on nmoo/git/remote runs its round trip. 46 tests run in-process, and pnpm smoke drives the real ssh and git binaries.
  • App: an opt-in account setting, "Allow SSH into open sandboxes", off by default. While it is on, each signed-in tab keeps one socket to the gateway, announces the project it has open, and serves shells on a TerminalSession and exec lines through a new quiet execLine path that shares the terminal's bashkit setup. Git channels are refused with a clear message for now.
  • SDK and lexicons: dev.nibling.ssh.attach, sshAccess on the settings record, attachToken, serviceDid, the rpc:dev.nibling.ssh.attach?aud=* scope, and config.sshGateway (VITE_NIBLING_SSH_GATEWAY at build time, none to disable).
  • Docs and CI: D25 in docs/VISION.md, with a one-line amendment to D22. deploy.yml deploys the gateway to Fly from the repo root on one machine. Needs the FLY_API_TOKEN pipeline secret.

Verified #

  • Every suite is green: gateway 46/46, sdk 150/150, lexicons pnpm check, app 148/148 node tests and 223/223 Playwright specs, typecheck clean everywhere.
  • Against production, from a real OpenSSH client with the Tangled key and a real tab signed in with the new scope: the listing shows the open project, node -p 6*7 returns 42, process.exit(3) returns 3, and an interactive shell gets a pty whose resize reaches the process.
  • The gateway is already live at ssh.nibling.dev on Fly app nibling-ssh, dedicated IPv4 and IPv6, certificate issued, DNS-only records in Cloudflare.

The new OAuth scope means a signed-in session has to sign in again before its tabs can attach. The setting is off until someone turns it on, so nothing changes for anyone who does not.

Known gaps, deliberate for v1 #

  • Typing exit in an SSH shell does not end the channel; disconnect from the SSH side.
  • Exec stdin reaches only a single launched command, not a bash pipeline.
  • The settings page shows the gateway host for the SSH command, which is wrong on loopback where the ports differ.
  • A session with no tab open is refused with the address to open. The container tier (headless kernel on Node) stays in the unmerged D24 and D26 drafts.
  • ssh2 has no post-quantum key exchange, so OpenSSH 10 prints its warning.
  • ssh handle@nibling.dev without the subdomain needs Cloudflare Spectrum, which needs the Pro plan.

Follow-ups agreed with other branches #

  • Presence: Peer.agent from an SSH env request (SetEnv NIB_AGENT=claude-code), gateway side in a follow-up here, tab side on top of this branch.
  • Git remote: the tab adapter to servePack from @nibling/sdk/git-remote after PR #2.
Commits 19

Run one gateway machine, since tabs and SSH sessions must meet on the same one
Deploy the gateway from the repo root with an explicit Dockerfile
Merge the SSH gateway service
Document the SSH gateway: usage, keys, tab attach, self-hosting
Add a Dockerfile and fly.toml for the SSH gateway
Add the nib-ssh-gateway CLI and a smoke check against the real ssh and git clients
Sign the rejected test token with a stranger's key instead of flipping padding bits
Relay SSH sessions to attached tabs: registry, channel state machine, tab attach, routing
Merge the app, SDK, and lexicon side of SSH attach
Attach open tabs to the SSH gateway when the account allows it (D25)
Run one line quietly in a fresh shell, with the terminal's commands
Verify tab service-auth tokens and resolve an account's SSH keys from its PDS records
Export the SDK's live config, so the app can read config.sshGateway
Parse an SSH exec command into a list, shell, exec, or git request
Mint SSH gateway attach tokens, read sshAccess, and name the hosted gateway
Record D25 on main and deploy the SSH gateway to Fly from CI
Add sshAccess to dev.nibling.actor.settings
Add dev.nibling.ssh.attach, the method a tab's gateway token is scoped to
Scaffold @nibling/ssh-gateway with the tab protocol (D25)
Sign up or Sign in to add to the discussion.