Table of Contents

Method ForwardRemotePortAsync

Namespace
SshSharp
Assembly
SshSharp.dll

ForwardRemotePortAsync(string, int, string, int, CancellationToken)

Remote port forwarding (ssh -R): asks the server to listen on bindAddress:remotePort and relays every connection made to it to localHost:localPort, as reached from this machine. The bind address is localhost for the server's loopback only (what ssh uses by default), an address, or empty for every address; sshd's GatewayPorts decides whether it honours anything but loopback. Port 0 lets the server pick one (see RemotePort).

public Task<SshRemotePortForwarder> ForwardRemotePortAsync(string bindAddress, int remotePort, string localHost, int localPort, CancellationToken cancellationToken = default)

Parameters

bindAddress string
remotePort int
localHost string
localPort int
cancellationToken CancellationToken

Returns

Task<SshRemotePortForwarder>

Exceptions

SshException

The server refused (sshd's AllowTcpForwarding, or the port is in use).