Table of Contents

Class SshProxy

Namespace
SshSharp
Assembly
SshSharp.dll

An HTTP or SOCKS proxy to reach the SSH server through, for networks that allow outbound connections only that way. Set it as Proxy or Proxy, or open a stream with ConnectAsync(string, int, CancellationToken) and pass it to ConnectAsync(Stream, SshClientOptions, bool, CancellationToken).

public sealed class SshProxy
Inheritance
SshProxy
Inherited Members

Remarks

Destination host names are sent to the proxy, which resolves them (as curl --socks5-hostname does), so names the proxy's network knows work, and local DNS does not see them. HTTP Basic and SOCKS 5 credentials cross the network to the proxy in the clear (as with every client of these protocols), so use them only with a proxy on a network you trust.

Properties

Credentials

The credentials sent to the proxy, if any (for SOCKS 4, just the user id).

Host

The proxy's host name or address.

Port

The proxy's port.

Type

The kind of proxy.

Methods

ConnectAsync(string, int, CancellationToken)

Connects to the proxy and asks it for a connection to host:port. The returned stream carries that connection; disposing it closes the connection to the proxy.

FromUri(Uri)

A proxy from a URI, as proxy settings are usually written: http://proxy:3128, socks5://proxy:1080, socks5h:// (the same: names are always resolved by the proxy), socks4:// or socks4a://, with optional user:password@ (percent-encoded). The port defaults to 8080 for HTTP and 1080 for SOCKS.

Http(string, int, NetworkCredential?)

An HTTP proxy, reached with CONNECT; credentials are sent with Basic authentication.

Socks4(string, int, string?)

A SOCKS 4 proxy (4a for host names), with an optional user id.

Socks5(string, int, NetworkCredential?)

A SOCKS 5 proxy; credentials are sent with username and password authentication (RFC 1929).

ToString()

The proxy's address and kind; never the credentials.