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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SshSession(
options):SshSession
Creates a disconnected session. Call connect or another operation to connect.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”SshSession
Methods
Section titled “Methods”close()
Section titled “close()”close():
void
Closes the active ssh2 connection and clears pending connection state.
Returns
Section titled “Returns”void
connect()
Section titled “connect()”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.
Returns
Section titled “Returns”Promise<Client>
execute()
Section titled “execute()”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.
Parameters
Section titled “Parameters”command
Section titled “command”string
string[]
options
Section titled “options”string
Record<string, string>
signal?
Section titled “signal?”AbortSignal
timeoutMs
Section titled “timeoutMs”number
Returns
Section titled “Returns”Promise<{ args: string[]; command: string; executionTimeMs: number; exitCode: number; stderr: string; stdout: string; success: boolean; timedOut?: boolean; }>
forwardOut()
Section titled “forwardOut()”forwardOut(
remoteHost,remotePort):Promise<ClientChannel>
Opens an SSH direct-tcpip channel to a host and port inside the Sandbox.
Parameters
Section titled “Parameters”remoteHost
Section titled “remoteHost”string
remotePort
Section titled “remotePort”number
Returns
Section titled “Returns”Promise<ClientChannel>