Documentation Index
Fetch the complete documentation index at: https://docs.microsandbox.dev/llms.txt
Use this file to discover all available pages before exploring further.
See SSH for usage flows.
Sandbox
ssh()
Return the SSH namespace for this sandbox.
Returns
| Type | Description |
|---|
SandboxSsh | SSH client and server helpers |
SandboxSsh
connect()
connect(opts?: SshClientOptions): Promise<SshClient>
Connect a native in-process SSH client to the sandbox.
Parameters
| Name | Type | Description |
|---|
| opts? | SshClientOptions | Client options |
Returns
| Type | Description |
|---|
Promise<SshClient> | Native SSH client session |
server()
server(opts?: SshServerOptions): Promise<SshServer>
Prepare a reusable SSH server endpoint.
Parameters
| Name | Type | Description |
|---|
| opts? | SshServerOptions | Server options |
Returns
| Type | Description |
|---|
Promise<SshServer> | Server endpoint |
SshClient
exec()
exec(command: string, opts?: SshExecOptions): Promise<SshOutput>
Run an SSH exec request and collect stdout, stderr, and exit status.
Parameters
| Name | Type | Description |
|---|
| command | string | Command string sent through SSH |
| opts? | SshExecOptions | Exec options |
Returns
| Type | Description |
|---|
Promise<SshOutput> | Captured output and status |
attach()
attach(opts?: SshAttachOptions): Promise<number>
Attach the local terminal to an interactive SSH shell.
Parameters
| Name | Type | Description |
|---|
| opts? | SshAttachOptions | Attach options |
Returns
| Type | Description |
|---|
Promise<number> | Exit code |
sftp()
sftp(): Promise<SftpClient>
Open an SFTP session over this SSH connection.
Returns
| Type | Description |
|---|
Promise<SftpClient> | SFTP client session |
close()
Close the native SSH client session.
SftpClient
| Method | Returns | Description |
|---|
| read(path) | Promise<Buffer> | Read a file into memory |
| write(path, data) | Promise<void> | Create or truncate a file |
| mkdir(path) | Promise<void> | Create a directory |
| removeFile(path) | Promise<void> | Remove a file |
| removeDir(path) | Promise<void> | Remove an empty directory |
| rename(oldPath, newPath) | Promise<void> | Rename a file or directory |
| realPath(path) | Promise<string> | Resolve a canonical path |
| readLink(path) | Promise<string> | Read a symlink target |
| symlink(target, linkPath) | Promise<void> | Create a symlink |
| close() | Promise<void> | Close the SFTP session |
SshServer
serveStdio()
serveStdio(): Promise<void>
Serve one SSH transport over stdin/stdout.
close()
Release the prepared server endpoint.
Types
SshOutput
| Property | Type | Description |
|---|
| status | number | Exit status code |
| stdout | Buffer | Captured stdout bytes |
| stderr | Buffer | Captured stderr bytes |
SshClientOptions
| Property | Type | Description |
|---|
| user | string | SSH login user. Defaults to root |
| term | string | Terminal name for interactive sessions |
| sftp | boolean | Enable or disable SFTP on the internal server |
SshExecOptions
| Property | Type | Description |
|---|
| tty | boolean | Request a PTY for the exec channel |
SshAttachOptions
| Property | Type | Description |
|---|
| term | string | Terminal name for the shell |
| detachKeys | string | Detach key sequence |
SshServerOptions
| Property | Type | Description |
|---|
| hostKeyPath | string | Override the host private key path |
| authorizedKeysPath | string | Override the authorized-keys path |
| user | string | Override the guest user used for exec requests |
| sftp | boolean | Enable or disable SFTP |