Files
archived-orca/src/shared/cloud-ssh.ts
T
Neil 984f29fc37 feat(cloud): SSH into Orca Cloud workspaces (orca ssh, ssh-proxy, VS Code/Cursor Remote-SSH) (#55)
* feat(cloud): SSH into Orca Cloud workspaces (orca ssh, ssh-proxy, VS Code/Cursor Remote-SSH)

- VM: unprivileged key-only sshd on 127.0.0.1:2222 (orca-sshd), host key and Orca-managed
  authorized_keys on the persistent disk; orca-ssh-keys entry point; provision extracts only the
  server binaries (dnf or apt, +1.5-2 MB) and unlocks the sandbox user for key logins.
- Control plane: POST/DELETE /v1/sandboxes/:id/ssh-keys runs the fixed entry point and answers
  the pinned host key; editor Remote-SSH server hosts on the egress allowlist.
- Desktop: per-workspace ed25519 keys in userData (0600), Orca-owned ssh_config + pinned
  known_hosts, ~/.ssh/config Include only after consent; wake -> key -> runtime port forward
  (openRuntimePortForward reason 'ssh'); revoke (deferred while asleep); SSH traffic keeps the
  workspace awake.
- CLI: orca ssh-proxy <workspace> (ProxyCommand) and orca ssh <workspace>.
- UI: Open in -> VS Code / Cursor over Remote SSH, SSH submenu (Copy SSH Command, Revoke),
  include consent dialog, progress/error toasts.

* fix(cloud-ssh): review fixes — no agent forwarding, reinstall per VM boot, wake to revoke

- ForwardAgent/ForwardX11 no in Orca's host blocks; AllowAgentForwarding no in the VM's sshd.
- Reinstall the key (idempotent; restarts sshd, re-pins the host key) once per VM boot, so a
  wiped disk, rollover or dead sshd heals on the next connection.
- Revoke wakes the VM to remove its copy; only an unreachable VM falls back to the queue.
- orca-ssh-keys rejects multi-line keys; sshd log truncated per start; audit log entries for
  ssh key add/remove; state parsed per entry; % escaped in ssh_config paths; ProxyCommand pinned
  to this app's profile; ssh-proxy flushes stdout before exit; --print shell-quotes; editors
  open via --folder-uri with a checked path; "Remove from ~/.ssh/config" + one-time backup.
2026-11-09 06:37:23 -08:00

73 lines
2.4 KiB
TypeScript

// SSH access to Orca Cloud workspaces: contract shared by main, the renderer and the CLI.
/** Desktop RPC the CLI's `orca ssh-proxy` calls: wakes the workspace and opens the SSH forward. */
export const CLOUD_SSH_TUNNEL_METHOD = 'cloudSsh.tunnel'
/** Desktop RPC `orca ssh` calls: ensures access and answers how to run ssh. */
export const CLOUD_SSH_PREPARE_METHOD = 'cloudSsh.prepare'
/** sshd inside every Orca Cloud VM (image/vm/orca-sshd); reachable only through the forward. */
export const CLOUD_SSH_REMOTE_PORT = 2222
export type CloudSshErrorCode =
| 'not_found'
| 'not_cloud'
| 'not_configured'
| 'asleep'
| 'wake_failed'
| 'unsupported_image'
| 'forward_failed'
| 'control_plane'
| 'cli_missing'
| 'editor_missing'
export type CloudSshFailure = { ok: false; code: CloudSshErrorCode; message: string }
export type CloudSshEditorKind = 'vscode' | 'cursor'
export type CloudSshEditor = {
/** Open In application id from settings. */
id: string
label: string
kind: CloudSshEditorKind
}
export type CloudSshStatus = {
/** An Orca Cloud workspace: the SSH actions apply. */
cloud: boolean
/** This device holds a key for it. */
hasAccess: boolean
/** The VM sleeps: the next SSH action wakes it first. */
asleep: boolean
alias: string | null
/** ~/.ssh/config includes Orca's config, so editors resolve the alias. */
includeInstalled: boolean
/** Installed editors whose Remote-SSH can open the workspace. */
editors: CloudSshEditor[]
}
export type CloudSshPrepareResult =
| { ok: true; alias: string; configFile: string; command: string; projectRoot: string }
| CloudSshFailure
/** "Copy SSH Command": `command` went to the clipboard; `displayCommand` abbreviates the home dir. */
export type CloudSshCopyResult =
| { ok: true; command: string; displayCommand: string }
| CloudSshFailure
export type CloudSshTunnelResult = { ok: true; host: '127.0.0.1'; port: number } | CloudSshFailure
export type CloudSshOpenEditorRequest = {
workspaceId: string
editorId: string
/** Set once the user agreed to the one-line Include in ~/.ssh/config. */
allowSshConfigInclude: boolean
}
export type CloudSshOpenEditorResult =
| { ok: true }
/** The exact line Orca would add to ~/.ssh/config, shown to the user before it does. */
| { ok: false; code: 'include_required'; includeLine: string }
| CloudSshFailure
export type CloudSshRevokeResult = { ok: true; removedFromWorkspace: boolean } | CloudSshFailure