Tunneling & forwarding

Forwarding entry points live on SSHConnection. The types on this page are the returned handles.

SSHTunnelChannel

public final class SSHTunnelChannel: @unchecked Sendable {
    public func read(maximumLength: Int = 32_768) async throws -> Data
    public func write(_ data: Data) async throws
    public func close() async throws
}

Callback overloads exist for all three. Returned by SSHConnection.openDirectTCPChannel.

SSHPortForward

public final class SSHPortForward: @unchecked Sendable {
    public let boundHost: String
    public let boundPort: UInt16

    public func close() async throws
}

Returned by startLocalForward, startRemoteForward, and startDynamicForward. boundHost / boundPort reflect the kernel-assigned values when you passed 0.