Table of Contents

Class SshClientOptions

Namespace
SshSharp
Assembly
SshSharp.dll

Options for SshClient.

public sealed class SshClientOptions
Inheritance
SshClientOptions
Inherited Members

Properties

AuthenticationBanner

Receives the server's pre-authentication banner (SSH_MSG_USERAUTH_BANNER, sshd's Banner), for example a legal notice. The text comes from the server: strip control characters before showing it in a terminal.

ChannelTimeouts

Idle timeouts by channel type, as OpenSSH's ChannelTimeout (9.2+) sets them on the client: a channel that carries no data in either direction for its type's timeout is closed, with an ordinary CLOSE. Its streams then end as when the server closes it, and a forwarded or tunnelled connection's local socket is closed. Empty by default (no timeouts). For example [new("direct-tcpip", TimeSpan.FromMinutes(10)), new("session", TimeSpan.Zero), new("*", TimeSpan.FromHours(1))]: the first entry whose type pattern matches applies (see SshChannelTimeout).

FipsMode

Restrict key exchange, host key, cipher and MAC algorithms to FIPS-approved ones (NIST curves and DH groups, RSA/ECDSA, AES, HMAC-SHA2). Curve25519, Ed25519 and ChaCha20-Poly1305 are excluded. This limits what is negotiated; it does not make the process FIPS-validated.

ForwardAgent

Forward this agent to the server (ssh -A, ForwardAgent yes): sessions ask the server to offer it, so programs there (ssh, git) can authenticate onward with your keys. Null (the default) forwards nothing. Only forward to servers you trust: while connected, anyone with enough rights on the server can use the agent to sign with your keys (not read them).

Gssapi

Authenticate with Kerberos (gssapi-with-mic) when the server offers it, before the other methods, as ssh does with GSSAPIAuthentication yes. Null (the default) does not try it. Needs .NET 10 (IsSupported).

HostKeyAlias

The name to look the host key up under (OpenSSH's HostKeyAlias), instead of the host name. Needed to use known_hosts when connecting over a Stream, where the host name is not known.

HostKeyVerifier

Decides whether to trust the server's host key: a KnownHostsVerifier, Pinned(params string[]), or your own (FromDelegate(Func<SshHostKeyContext, CancellationToken, ValueTask<bool>>)). There is deliberately no default: accepting unknown keys silently would defeat the purpose of host authentication.

KeepAliveCountMax

After this many keep-alive intervals without hearing from the server, the connection is declared dead and fails with Timeout (OpenSSH's ServerAliveCountMax). Default 3.

KeepAliveInterval

Send a keep-alive when the server has been silent this long (OpenSSH's ServerAliveInterval). Null (the default) sends none. Keep-alives detect a dead connection and stop idle NAT and firewall timeouts from dropping it.

KeyboardInteractive

Answers keyboard-interactive authentication (RFC 4256): one-time codes, PAM prompts, or a password the server asks for this way. Called once per round with the server's questions; return one answer per prompt, or null to give up on the method. Tried after PrivateKeys and before Password, like ssh.

LocalEndPoint

The local address (and usually port 0) to connect from, as ssh -b, for machines on several networks; null lets the system choose. Only destination addresses of the same family are tried. Used by ConnectAsync(string, int, SshClientOptions, CancellationToken), also for the connection to Proxy.

Logger

Receives diagnostics (connection, algorithms, authentication outcome, channels, rekeys). Never receives passwords or command text. Default: no logging.

MaxCommandOutputBytes

The most output (stdout plus stderr) RunCommandAsync(string, CancellationToken) will collect before failing. Default 128 MiB.

MaxForwardedConnections

The most connections the server may have forwarded to this client at once, across all remote forwardings (port, dynamic and Unix-socket). Each one makes a connection on this machine, so this bounds what a misbehaving server can make it open; above it, the server's channel is refused (resource shortage) and its client sees the connection fail. Default 1000.

ObscureKeystrokeTiming

Hide the timing of keystrokes in sessions with a terminal, as OpenSSH's ObscureKeystrokeTiming (9.5+) does: while someone types, small writes to StandardInput are sent only once per interval (a write completes when its interval comes), and the intervals with nothing typed carry a chaff packet of the same size, for a random 1 to 3 seconds after the last key. Someone watching the encrypted traffic then cannot tell keys, or the time between them, from the packets. Larger writes (256 bytes or more, such as a paste) go at once. Chaff is sent only to servers that announce ping@openssh.com (OpenSSH 9.5+). Null (the default) sends every write at once. ssh uses 20 ms, and so does ConnectAsync(string, SshConfigConnectOptions?, CancellationToken) unless the config says otherwise. Between 1 ms and 1 second, as ssh allows.

Password

The password, if used. Tried after PrivateKeys and KeyboardInteractive with the password method. When the server offers only keyboard-interactive (common with PAM) and there is no handler, it answers a round that asks for exactly one hidden input.

PrivateKeys

Keys for public-key authentication, tried in order (load them with LoadAsync(string, string?, CancellationToken)). The client does not dispose them. The server is asked whether it accepts each key before anything is signed.

Proxy

An HTTP or SOCKS proxy to reach the server through, for ConnectAsync(string, int, SshClientOptions, CancellationToken). The server's host name is resolved by the proxy. Ignored when connecting over a stream you opened.

RekeyAfterBytes

Negotiate new keys after this many bytes have been transferred under the current ones. Default 1 GiB (RFC 4253 section 9). Values above 64 GiB (2^32 cipher blocks, the limit OpenSSH applies) are capped, and keys are also renewed every 2^31 packets.

RekeyAfterTime

Negotiate new keys after the current ones have been in use this long. Default 1 hour (RFC 4253 section 9).

UserName

The user to authenticate as.