Skip to main content
SSH gives a sandbox a familiar interface without putting an SSH daemon inside the guest. microsandbox speaks SSH on the host side, then forwards shells, remote commands, SFTP file operations, and local TCP forwarding into the sandbox. Use it when you want existing SSH tools to work with a sandbox, or when you want SDK code to use SSH semantics while still going through microsandbox. There are two ways to connect:
  • Native sessions use the built-in microsandbox SSH client. No host ssh binary, TCP listener, or authorized key is required, which makes it the quickest path for a shell from msb or SSH semantics from the SDK.
  • External clients serve the sandbox as an SSH server so standard tools such as ssh, sftp, and ProxyCommand can connect.
SSH sessions disconnect after 10 minutes without traffic by default. Change or disable the inactivity timeout.

Native sessions

Native sessions keep the SSH protocol boundary but do not expose a listener.

CLI

With no remote command, the CLI opens an interactive shell. With --, the remaining tokens become the SSH command string and run through the sandbox shell.
If a sandbox name collides with an SSH subcommand such as serve or authorize, use --name:

SDK

Interactive attach

SDK clients can attach the local terminal to an SSH shell. This requires a real terminal.

SFTP

The native SSH client can open SFTP over the same SSH connection.

External clients

External client mode exposes a sandbox as an SSH server for tools that already speak SSH. This is the closest match for normal SSH usage: authorize a public key, serve the sandbox, then connect with ssh or sftp.

Authorize a key

microsandbox appends keys to <MSB_HOME>/ssh/authorized_keys.

TCP listener

The default listener is 127.0.0.1:2222.
Choose a different bind address or port when needed:
Binding to 0.0.0.0 exposes the SSH listener beyond the local machine. Keep the default loopback bind unless you intentionally want remote clients to connect.

Port forwarding

OpenSSH local (-L) and dynamic (-D) forwarding work through the listener:
microsandbox opens forwarded TCP connections from inside the sandbox, so destination reachability follows the sandbox’s network policy. 127.0.0.1 refers to the sandbox’s loopback interface rather than the host’s. microsandbox does not support reverse forwarding (-R) or stream-local forwarding.

ProxyCommand

msb ssh serve --stdio carries a single SSH connection over stdin/stdout instead of a TCP listener. Point OpenSSH at it with ProxyCommand so standard SSH tools can reach the sandbox by host alias. Add an entry to your ~/.ssh/config:
~/.ssh/config
The Host value is the alias you connect to, and devbox is the sandbox name passed to msb ssh serve. Once it is in place, the alias works with any OpenSSH-based tool:
Editors that build on OpenSSH, such as VS Code Remote-SSH, connect to the devbox.msb host the same way.

Inactivity timeout

SSH sessions disconnect after 10 minutes without SSH traffic by default. Any SSH input or output resets the timer. This transport timeout is independent of the sandbox lifecycle idle timeout: an SSH disconnect does not stop the sandbox. Set a global default in ~/.microsandbox/config.json. Use 0 to disable the timeout:
Override the global value for one CLI session with --inactivity-timeout 30m, or disable it with --no-inactivity-timeout. The same overrides are available when opening native clients or preparing server endpoints through an SDK:
For exact SDK signatures, see the SSH reference for TypeScript, Rust, Python, or Go.