The Maverick.NET SSH API

ForwardingClient Class

Provides management of port forwarding connections and active tunnels.

For a list of all members of this type, see ForwardingClient Members.

System.Object
   Maverick.Forwarding.ForwardingClient

[Visual Basic]
Public Class ForwardingClient
[C#]
public class ForwardingClient

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

Three types of forwarding are provided by both SSH protocol versions, they are:

Local forwarding allows you to transfer data (or socket connections if you prefer) from the local computer to a destination on the remote computer/network. For example you could setup a local forwarding to listen for connection's on port 110 (the POP3 protocol) and forwarding those connections to the port 110 at the remote side of the connection. This secures the data by encrypting it within the SSH connection making the insecure POP3 protocol secure. It is normally the practice to deliver the connection to a socket on the localhost of the remote computer to ensure that the data is not transmitted over any other insecure network.

Remote forwarding is simply the reverse of this operation; a request is made to the server to listen on a particular port and any connections made are forwarded to the local computer where they are delivered to the required destination.

The third type of forwarding is X forwarding and this is available for you to forward X11 data from the remote machine to a local X server. This forwarding enables you to run X applications on your remote desktop.

The use of this client is a simple procedure. First create an instance once you have an authenticated SSHClient. You can then use the methods to start local forwarding or request remote forwarding. This implementation manages all the connections and manages threads to transfer the data from sockets to the forwarding channels. All you are required to do is to select the forwarding configuration you require.

The are several restrictions you must follow if you require protocol independece so that your code will work with both SSH1 and SSH2 servers. SSH1 remote forwarding requests MUST be made before you start the users shell and local forwarding's MUST only be started once you have started the users shell. With SSH1 you must always start the user's shell in order to perform port forwarding as this places the protocol into interactive mode. SSH2 does not place any restrictions as to when a remote forwarding is requesting or local forwarding started.

This class also REQUIRES that the SSHClient instance is created with the buffered option. This is to enable a background thread to service incoming channel and data messages.

The X forwarding managed by this class should be requested before starting any sessions. When X forwarding is requested a fake MIT-MAGIC-COOKIE is supplied to the remote machine which protects your real authentication cookies from being detected. When an X11 request comes in the fake cookie is replaced with your real cookie by looking at your .Xauthority file. If in the event that a real cookie cannot be found there are additional methods to either specify an alternative path to your .Xauthority file or to specify the cookie itself. Please note that X forwarding provided by this class does not operate over Unix Domain sockets so you should ensure that your X server is listening on a TCP port.

Requirements

Namespace: Maverick.Forwarding

Assembly: Maverick.NET (in Maverick.NET.dll)

See Also

ForwardingClient Members | Maverick.Forwarding Namespace