Skip to main content
Reach a running sandbox over SSH: open an in-process client, run commands or attach an interactive shell, transfer files over SFTP, or expose the sandbox as a server endpoint. See SSH for usage flows.

SandboxSshOps

The SSH namespace for a sandbox, returned by sb.ssh(). It opens in-process SSH clients and prepares server endpoints against the running sandbox.

sb.ssh()

Return the SSH namespace for this sandbox. The returned object exposes openClient() and prepareServer().

Returns

SSH client and server helpers.

ssh.openClient()

Open a native in-process SSH client connected to the sandbox.

Parameters

Optional client options: login user, terminal name, SFTP toggle, and inactivity timeout.

Returns

Connected SSH client session.

ssh.prepareServer()

Prepare a reusable SSH server endpoint backed by the sandbox.

Parameters

Optional server options: host key path, authorized-keys path, guest user, SFTP toggle, and inactivity timeout.

Returns

Prepared server endpoint.

SshClient

A native in-process SSH client session, returned by openClient(). Run commands, attach an interactive shell, or open an SFTP session over the same connection. Close it with close() when done.

client.exec()

Run an SSH exec request and collect stdout, stderr, and the exit status.

Parameters

commandstring
Command string sent through SSH.
Optional exec options: request a PTY for the channel.

Returns

Captured output and exit status.

client.attach()

Attach the local terminal to an interactive SSH shell. Resolves with the shell’s exit code once the session ends.

Parameters

Optional attach options: terminal name and detach key sequence.

Returns

Promise<number>
Exit code of the interactive shell.

client.sftp()

Open an SFTP session over this SSH connection for file transfer and remote filesystem operations.

Returns

SFTP client session.

client.close()

Close the native SSH client session.

SftpClient

An SFTP session over an SshClient connection, returned by sftp(). Read and write files, manage directories, and resolve symlinks on the remote sandbox. Close it with close() when done.

sftp.read()

Read a remote file into memory.

Parameters

pathstring
Remote file path.

Returns

Promise<Buffer>
File contents.

sftp.write()

Create or truncate a remote file and write the given bytes.

Parameters

pathstring
Remote file path.
dataBuffer
Bytes to write.

sftp.mkdir()

Create a remote directory.

Parameters

pathstring
Remote directory path.

sftp.removeFile()

Remove a remote file.

Parameters

pathstring
Remote file path.

sftp.removeDir()

Remove an empty remote directory.

Parameters

pathstring
Remote directory path.

sftp.rename()

Rename or move a remote file or directory.

Parameters

oldPathstring
Existing remote path.
newPathstring
New remote path.

sftp.realPath()

Resolve a remote path to its canonical, absolute form.

Parameters

pathstring
Remote path to resolve.

Returns

Promise<string>
Canonical absolute path.
Read the target of a remote symlink.

Parameters

pathstring
Remote symlink path.

Returns

Promise<string>
The symlink target.
Create a remote symlink at linkPath pointing to target.

Parameters

targetstring
What the symlink points to.
linkPathstring
Path of the symlink itself.

sftp.close()

Close the SFTP session.

SshServer

A prepared SSH server endpoint, returned by prepareServer(). Serves SSH transports over standard streams and is released with close().

server.serveConnection()

Serve one SSH transport over stdin/stdout. Resolves when the connection ends.

server.close()

Release the prepared server endpoint.

Types

SshOutput

Returned by exec()

Captured result of an SSH exec request.

SshClientOptions

Used by openClient()

Options for opening an SSH client. All fields are optional.

SshExecOptions

Used by exec()

Options for an SSH exec request. All fields are optional.

SshAttachOptions

Used by attach()

Options for attaching an interactive SSH shell. All fields are optional.

SshServerOptions

Used by prepareServer()

Options for preparing an SSH server endpoint. All fields are optional.