Table of Contents

Class SshRemotePortForwarder

Namespace
SshSharp
Assembly
SshSharp.dll

A remote port forwarding (ssh -R) started by ForwardRemotePortAsync(string, int, string, int, CancellationToken): the server listens on BindAddress:RemotePort, and each connection made to it is relayed to LocalHost:LocalPort as reached from this machine. A remote dynamic forwarding (ForwardRemoteDynamicPortAsync(string, int, Func<string, int, bool>?, CancellationToken), IsDynamic) instead answers each connection as a SOCKS proxy and connects where it asks. Dispose it to cancel the forwarding on the server and close the forwarded connections.

public sealed class SshRemotePortForwarder : IAsyncDisposable
Inheritance
SshRemotePortForwarder
Implements
Inherited Members

Properties

ActiveConnections

How many forwarded connections are open now.

BindAddress

The address the server listens on, as requested (localhost for its loopback, empty for every address).

IsDynamic

Whether this is a remote dynamic forwarding (ssh -R port): each forwarded connection is a SOCKS request answered here, and LocalHost is empty and LocalPort 0.

LocalHost

Where each forwarded connection goes, as reached from this machine.

LocalPort

The port on LocalHost.

RemotePort

The port the server listens on (the one it picked when 0 was asked for).

Methods

DisposeAsync()

Cancels the forwarding on the server (cancel-tcpip-forward) and closes every forwarded connection.