Skip to content

Class: SshSession

Verified SSH transport using OpenSSH commands and ssh2 direct forwarding.

The first successful connection can persist a gateway fingerprint through SshSessionOptions.rememberHost. Later connections reject a changed fingerprint. Native commands use the dedicated SshSessionOptions.knownHostsPath instead of disabling verification.

new SshSession(options): SshSession

Creates a disconnected session. Call connect or another operation to connect.

SshSessionOptions

SshSession

close(): void

Closes the active ssh2 connection and clears pending connection state.

void


connect(): Promise<Client>

Opens or reuses a verified SSH connection.

A failed private service-direct hostname can retry its resolved public IPv4 addresses while preserving host-key verification against the original gateway identity.

Promise<Client>


execute(command, args, options): Promise<{ args: string[]; command: string; executionTimeMs: number; exitCode: number; stderr: string; stdout: string; success: boolean; timedOut?: boolean; }>

Runs one command through native OpenSSH and captures stdout, stderr, exit status, duration, and timeout state.

string

string[]

string

Record<string, string>

AbortSignal

number

Promise<{ args: string[]; command: string; executionTimeMs: number; exitCode: number; stderr: string; stdout: string; success: boolean; timedOut?: boolean; }>


forwardOut(remoteHost, remotePort): Promise<ClientChannel>

Opens an SSH direct-tcpip channel to a host and port inside the Sandbox.

string

number

Promise<ClientChannel>