Typical flow
SandboxSshOps
The SSH namespace for a sandbox, returned bysb.ssh(). It opens in-process SSH clients and prepares server endpoints against the running sandbox.
sb.ssh()
Example
Example
openClient() and prepareServer().
Returns
SSH client and server helpers.
ssh.openClient()
Example
Example
Parameters
optsSshClientOptionsOptional client options: login user, terminal name, SFTP toggle.
Returns
Connected SSH client session.
ssh.prepareServer()
Example
Example
Parameters
optsSshServerOptionsOptional server options: host key path, authorized-keys path, guest user, SFTP toggle.
Returns
Prepared server endpoint.
SshClient
A native in-process SSH client session, returned byopenClient(). Run commands, attach an interactive shell, or open an SFTP session over the same connection. Close it with close() when done.
client.exec()
Example
Example
Parameters
commandstringCommand string sent through SSH.
optsSshExecOptionsOptional exec options: request a PTY for the channel.
Returns
Captured output and exit status.
client.attach()
Example
Example
Parameters
optsSshAttachOptionsOptional attach options: terminal name and detach key sequence.
Returns
Promise<number>
Exit code of the interactive shell.
client.sftp()
Example
Example
Returns
SFTP client session.
client.close()
Example
Example
SftpClient
An SFTP session over anSshClient 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()
Example
Example
Parameters
pathstringRemote file path.
Returns
Promise<Buffer>
File contents.
sftp.write()
Example
Example
Parameters
pathstringRemote file path.
dataBufferBytes to write.
sftp.mkdir()
Example
Example
Parameters
pathstringRemote directory path.
sftp.removeFile()
Example
Example
Parameters
pathstringRemote file path.
sftp.removeDir()
Example
Example
Parameters
pathstringRemote directory path.
sftp.rename()
Example
Example
Parameters
oldPathstringExisting remote path.
newPathstringNew remote path.
sftp.realPath()
Example
Example
Parameters
pathstringRemote path to resolve.
Returns
Promise<string>
Canonical absolute path.
sftp.readLink()
Example
Example
Parameters
pathstringRemote symlink path.
Returns
Promise<string>
The symlink target.
sftp.symlink()
Example
Example
linkPath pointing to target.
Parameters
targetstringWhat the symlink points to.
linkPathstringPath of the symlink itself.
sftp.close()
Example
Example
SshServer
A prepared SSH server endpoint, returned byprepareServer(). Serves SSH transports over standard streams and is released with close().
server.serveConnection()
Example
Example
server.close()
Example
Example
Types
SshOutput
Returned by exec()
Captured result of an SSH exec request.| Property | Type | Description |
|---|---|---|
| status | number | Exit status code |
| stdout | Buffer | Captured stdout bytes |
| stderr | Buffer | Captured stderr bytes |
SshClientOptions
Used by openClient()
Options for opening an SSH client. All fields are optional.| Property | Type | Description |
|---|---|---|
| user | string | SSH login user |
| term | string | Terminal name for interactive sessions |
| sftp | boolean | Enable or disable SFTP on the internal server |
SshExecOptions
Used by exec()
Options for an SSH exec request. All fields are optional.| Property | Type | Description |
|---|---|---|
| tty | boolean | Request a PTY for the exec channel |
SshAttachOptions
Used by attach()
Options for attaching an interactive SSH shell. All fields are optional.| Property | Type | Description |
|---|---|---|
| term | string | Terminal name for the shell |
| detachKeys | string | Detach key sequence |
SshServerOptions
Used by prepareServer()
Options for preparing an SSH server endpoint. All fields are optional.| 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 |