SshTransportConnection
Defined in: src/protocols/ssh/transport/SshTransportConnection.ts:91
Live SSH transport connection over a TCP socket.
Runs the SSH identification exchange and key exchange handshake on the supplied socket, then provides an encrypted packet send/receive interface for higher-level SSH layers (authentication, connection, SFTP subsystem).
Usage:
const conn = new SshTransportConnection();const result = await conn.connect(socket); // runs handshakeconn.sendPayload(payload); // post-NEWKEYS sendfor await (const payload of conn.receivePayloads()) { ... }conn.disconnect();Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SshTransportConnection(options?: SshTransportConnectionOptions): SshTransportConnection;Defined in: src/protocols/ssh/transport/SshTransportConnection.ts:108
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options | SshTransportConnectionOptions |
Returns
Section titled “Returns”SshTransportConnection
Methods
Section titled “Methods”connect()
Section titled “connect()”connect(socket: Socket): Promise<SshTransportHandshakeResult>;Defined in: src/protocols/ssh/transport/SshTransportConnection.ts:115
Runs the SSH handshake on a TCP-connected socket. Resolves when NEWKEYS completes and the transport is ready for encrypted messages. Rejects on socket error, abort, or protocol failure.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
socket | Socket |
Returns
Section titled “Returns”Promise<SshTransportHandshakeResult>
disconnect()
Section titled “disconnect()”disconnect(reason?: SshDisconnectReason, description?: string): void;Defined in: src/protocols/ssh/transport/SshTransportConnection.ts:336
Sends SSH_MSG_DISCONNECT and ends the socket. Safe to call multiple times; subsequent calls are no-ops.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
reason | SshDisconnectReason | SshDisconnectReason.BY_APPLICATION |
description | string | "" |
Returns
Section titled “Returns”void
isConnected()
Section titled “isConnected()”isConnected(): boolean;Defined in: src/protocols/ssh/transport/SshTransportConnection.ts:363
Returns
Section titled “Returns”boolean
receivePayloads()
Section titled “receivePayloads()”receivePayloads(): AsyncGenerator<Buffer<ArrayBufferLike>>;Defined in: src/protocols/ssh/transport/SshTransportConnection.ts:322
Async generator that yields inbound SSH payloads (post-NEWKEYS).
Transparent handling:
- SSH_MSG_IGNORE (2) and SSH_MSG_DEBUG (4) are silently dropped.
- SSH_MSG_DISCONNECT (1) from the server throws a
ConnectionError. - Socket error or close terminates the generator.
Returns
Section titled “Returns”AsyncGenerator<Buffer<ArrayBufferLike>>
sendPayload()
Section titled “sendPayload()”sendPayload(payload: Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike>): void;Defined in: src/protocols/ssh/transport/SshTransportConnection.ts:306
Sends an SSH payload over the encrypted transport. The payload must start with the SSH message type byte.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
payload | Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike> |
Returns
Section titled “Returns”void