Skip to main content

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()

ssh(): SandboxSsh
Return the SSH namespace for this sandbox. Returns
TypeDescription
SandboxSshSSH client and server helpers

SandboxSsh


connect()

connect(opts?: SshClientOptions): Promise<SshClient>
Connect a native in-process SSH client to the sandbox. Parameters
NameTypeDescription
opts?SshClientOptionsClient options
Returns
TypeDescription
Promise<SshClient>Native SSH client session

server()

server(opts?: SshServerOptions): Promise<SshServer>
Prepare a reusable SSH server endpoint. Parameters
NameTypeDescription
opts?SshServerOptionsServer options
Returns
TypeDescription
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
NameTypeDescription
commandstringCommand string sent through SSH
opts?SshExecOptionsExec options
Returns
TypeDescription
Promise<SshOutput>Captured output and status

attach()

attach(opts?: SshAttachOptions): Promise<number>
Attach the local terminal to an interactive SSH shell. Parameters
NameTypeDescription
opts?SshAttachOptionsAttach options
Returns
TypeDescription
Promise<number>Exit code

sftp()

sftp(): Promise<SftpClient>
Open an SFTP session over this SSH connection. Returns
TypeDescription
Promise<SftpClient>SFTP client session

close()

close(): Promise<void>
Close the native SSH client session.

SftpClient

MethodReturnsDescription
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()

close(): Promise<void>
Release the prepared server endpoint.

Types

SshOutput

PropertyTypeDescription
statusnumberExit status code
stdoutBufferCaptured stdout bytes
stderrBufferCaptured stderr bytes

SshClientOptions

PropertyTypeDescription
userstringSSH login user. Defaults to root
termstringTerminal name for interactive sessions
sftpbooleanEnable or disable SFTP on the internal server

SshExecOptions

PropertyTypeDescription
ttybooleanRequest a PTY for the exec channel

SshAttachOptions

PropertyTypeDescription
termstringTerminal name for the shell
detachKeysstringDetach key sequence

SshServerOptions

PropertyTypeDescription
hostKeyPathstringOverride the host private key path
authorizedKeysPathstringOverride the authorized-keys path
userstringOverride the guest user used for exec requests
sftpbooleanEnable or disable SFTP