SSH and VS Code
Use your own ssh, scp, rsync, port forwards and
VS Code Remote-SSH with a kosa8 Cloud sandbox. Nothing listens on port 22: SSH is carried over the
sandbox's terminal WebSocket, which your API key already
authenticates.
Connect#
kosa8 cloud ssh sbx_… # a shell kosa8 cloud ssh sbx_… -- -L 3000:localhost:3000 # and forward a port kosa8 cloud ssh sbx_… -- uname -a # run one command
Everything after -- goes to ssh. If this machine has no
ssh client, kosa8 cloud ssh opens the plain terminal instead
(kosa8 cloud terminal).
ssh kosa8-ID, scp and VS Code#
kosa8 cloud ssh-config --write # adds a block to ~/.ssh/config (a later --write replaces it) ssh kosa8-sbx_… scp ./data.csv kosa8-sbx_…:/workspace/ rsync -a ./src/ kosa8-sbx_…:/workspace/src/
Without --write, kosa8 cloud ssh-config prints the stanza for you to
paste. With no ID it matches every kosa8-sbx_… host; with IDs it prints one stanza each:
Host kosa8-sbx_* ProxyCommand /usr/local/bin/kosa8 cloud ssh --stdio %n User root IdentityFile ~/.kosa8/ssh/id_ed25519 IdentitiesOnly yes HostKeyAlias %n UserKnownHostsFile ~/.kosa8/ssh/known_hosts StrictHostKeyChecking accept-new ServerAliveInterval 30
VS Code: install the Remote - SSH extension, run kosa8 cloud ssh-config
--write, then Remote-SSH: Connect to Host… and type kosa8-sbx_…. Open
/workspace. VS Code downloads its server into the sandbox, so the sandbox needs egress
to update.code.visualstudio.com; if your egress rules
block it, set "remote.SSH.localServerDownload": "always" so VS Code downloads it here and
copies it over. Cursor and other editors built on VS Code work the same way.
How it works#
kosa8 cloud ssh --stdio ID, the ProxyCommand, asks the API for a terminal (POST /v1/sandboxes/{id}/terminal, scopesandboxes:write) running a short setup script instead of a shell. A sleeping sandbox is woken first.- The script puts the terminal in raw mode (
stty raw -echo), so every byte passes unchanged. It findssshd, installingopenssh-serverwith the image's package manager if there is none. It adds this machine's kosa8 key to~/.ssh/authorized_keys, then runssshd -i, which speaks SSH on the terminal itself. Password login is off. - The CLI sends nothing until the script says sshd is ready. Before then, what the sandbox prints (package installs, errors) goes to your terminal as diagnostics.
- Your key is kosa8's own,
~/.kosa8/ssh/id_ed25519, made on first use. Delete the~/.kosa8/sshdirectory to make a new one. - The sandbox's host key is meant to be kept in
/workspace/.kosa8/ssh, so it stays the same across connections, sleep and wake, and is checked against~/.kosa8/ssh/known_hosts. Known issue: on kosa8 Cloud today/workspace/.kosa8is a file the host keeps, so the key is made afresh on every connection and the second connection to a sandbox fails withHost key verification failed. Until that is fixed, remove the sandbox's line from~/.kosa8/ssh/known_hostsbefore you connect again (the first connection to each sandbox works). - Each connection is one terminal, recorded in the audit log as
sandbox.terminal_open. What you type is not recorded.
Limits#
- Like every terminal, each SSH connection runs in its own container from the sandbox's image,
with
/workspacemounted. Work in/workspace. In a persistent sandbox, packages installed over SSH outside/workspaceare not seen byexec. - An image without
sshdinstalls it on every connection, which takes a few seconds and needs egress to the image's package mirror. Addopenssh-serverto your image to skip that. The image needssttyandsh, which nearly every Linux image has. - You log in as
root, the user commands run as. - The terminal URL lasts five minutes, but only until you connect. After that, a session lasts as long as you stay connected.
Something wrong or missing? Edit this page, or write to contact@kosa8.com.