Table of Contents

Method OpenTcpTunnelAsync

Namespace
SshSharp
Assembly
SshSharp.dll

OpenTcpTunnelAsync(string, int, CancellationToken)

Opens a TCP connection from the server to host:port (a direct-tcpip channel, what ssh -L and ProxyJump use) and returns it as a stream. The host name is resolved by the server, so it can name machines only the server reaches. Disposing the stream closes the connection.

public Task<Stream> OpenTcpTunnelAsync(string host, int port, CancellationToken cancellationToken = default)

Parameters

host string
port int
cancellationToken CancellationToken

Returns

Task<Stream>

Exceptions

SshException

The server refused (for example sshd's AllowTcpForwarding no) or could not connect.