mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* 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.
37 lines
1.6 KiB
Bash
Executable File
37 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# `orca-ssh-keys add|remove`: adds or removes one desktop's key in the Orca-managed authorized_keys
|
|
# of this VM's sshd, then makes sure sshd runs. The control plane passes the key in
|
|
# ORCA_SSH_PUBLIC_KEY (`ssh-ed25519 <base64> <comment>`), never on the command line. Keys are
|
|
# matched by their base64 blob, so a renamed comment cannot keep a revoked key alive.
|
|
# Prints orca-sshd's {"port":...,"user":...,"hostKey":...} line on success.
|
|
set -euo pipefail
|
|
umask 077
|
|
SSH_DIR="$HOME/.orca-sandbox/ssh"
|
|
action="${1:-}"
|
|
key="${ORCA_SSH_PUBLIC_KEY:-}"
|
|
# grep matches per line: a second line could carry key options past the check below.
|
|
case "$key" in *$'\n'* | *$'\r'*) echo 'invalid public key' >&2; exit 2 ;; esac
|
|
# One line, ed25519 only, a plain comment: nothing that sshd would read as key options.
|
|
if ! printf '%s' "$key" | grep -Eq '^ssh-ed25519 [A-Za-z0-9+/]{68} [A-Za-z0-9@._:+-]{1,200}$'; then
|
|
echo 'invalid public key' >&2
|
|
exit 2
|
|
fi
|
|
blob="$(printf '%s' "$key" | cut -d' ' -f2)"
|
|
mkdir -p "$SSH_DIR"
|
|
chmod 0700 "$HOME/.orca-sandbox" "$SSH_DIR"
|
|
exec 7>"$SSH_DIR/keys.lock"
|
|
flock -w 30 7
|
|
touch "$SSH_DIR/authorized_keys"
|
|
next="$(mktemp "$SSH_DIR/authorized_keys.XXXXXX")"
|
|
# Drop the key wherever it appears (with or without options), then append it on add.
|
|
awk -v blob="$blob" '{ for (i = 1; i <= NF; i++) if ($i == blob) next; print }' \
|
|
"$SSH_DIR/authorized_keys" >"$next"
|
|
case "$action" in
|
|
add) printf '%s\n' "$key" >>"$next" ;;
|
|
remove) ;;
|
|
*) rm -f "$next"; echo 'usage: orca-ssh-keys add|remove' >&2; exit 2 ;;
|
|
esac
|
|
chmod 0600 "$next"
|
|
mv -f "$next" "$SSH_DIR/authorized_keys"
|
|
exec /opt/orca/bin/orca-sshd
|