Table of Contents

Method ForwardLocalPortAsync

Namespace
SshSharp
Assembly
SshSharp.dll

ForwardLocalPortAsync(IPEndPoint, string, int, CancellationToken)

Local port forwarding (ssh -L): listens on localEndPoint and forwards every connection made to it through the server to remoteHost:remotePort. Use a loopback address unless other machines should be able to use the tunnel, and port 0 to let the system pick a free port (see LocalEndPoint). Forwarding stops when the forwarder or the client is disposed, or the connection ends.

public Task<SshLocalPortForwarder> ForwardLocalPortAsync(IPEndPoint localEndPoint, string remoteHost, int remotePort, CancellationToken cancellationToken = default)

Parameters

localEndPoint IPEndPoint
remoteHost string
remotePort int
cancellationToken CancellationToken

Returns

Task<SshLocalPortForwarder>

Exceptions

SocketException

The local endpoint could not be bound (for example the port is in use).