Table of Contents

Class SshClientSettings

Namespace
Tmds.Ssh
Assembly
Tmds.Ssh.dll

Settings for configuring SshClient.

public sealed class SshClientSettings
Inheritance
SshClientSettings
Inherited Members

Constructors

SshClientSettings()

Creates default settings.

public SshClientSettings()

SshClientSettings(string)

Creates settings for the specified destination.

public SshClientSettings(string destination)

Parameters

destination string

The destination in format [user@]host[:port].

Properties

AutoConnect

Gets or sets whether to automatically connect when the client is used.

public bool AutoConnect { get; set; }

Property Value

bool

Remarks

Defaults to true.

AutoReconnect

Gets or sets whether to automatically reconnect when the client is used after an unexpected disconnect.

public bool AutoReconnect { get; set; }

Property Value

bool

Remarks

Defaults to false.

BannerHandler

Gets or sets the BannerHandler delegate.

public BannerHandler? BannerHandler { get; set; }

Property Value

BannerHandler

Remarks

When set, the delegate is called for each banner the server sends during authentication. When unset, banners are ignored.

BatchMode

Gets or sets whether to enable batch mode (no interactive prompts).

public bool BatchMode { get; set; }

Property Value

bool

Remarks

Defaults to false.

ClientKeyAlgorithms

Gets or sets the signature algorithms allowed for client key authentication.

public AlgorithmList? ClientKeyAlgorithms { get; set; }

Property Value

AlgorithmList

Remarks

This limits how Credentials can be used for authentication based on the key signature algorithms. When null, all supported algorithms are allowed.

ConnectTimeout

Gets or sets the connection timeout.

public TimeSpan ConnectTimeout { get; set; }

Property Value

TimeSpan

Remarks

Defaults to 15 seconds.

Credentials

Gets or sets the credentials for authentication.

public List<Credential> Credentials { get; set; }

Property Value

List<Credential>

Remarks

Defaults to DefaultCredentials.

DefaultCredentials

Gets the default Credential list used for authentication.

public static IReadOnlyList<Credential> DefaultCredentials { get; }

Property Value

IReadOnlyList<Credential>

Remarks

This contains private key credentials from ~/.ssh/id_ed25519, ~/.ssh/id_ecdsa, and ~/.ssh/id_rsa; certificate credentials from ~/.ssh/id_ed25519-cert.pub, ~/.ssh/id_ecdsa-cert.pub, and ~/.ssh/id_rsa-cert.pub; SshAgentCredentials, KerberosCredential, and NoCredential.

DefaultGlobalKnownHostsFilePaths

Gets the default global known hosts file paths.

public static IReadOnlyList<string> DefaultGlobalKnownHostsFilePaths { get; }

Property Value

IReadOnlyList<string>

Remarks

On Unix this contains /etc/ssh/ssh_known_hosts and /etc/ssh/ssh_known_hosts2. On Windows this contains %ProgramData%/ssh/ssh_known_hosts and %ProgramData%/ssh/ssh_known_hosts2.

DefaultUserKnownHostsFilePaths

Gets the default user known hosts file paths.

public static IReadOnlyList<string> DefaultUserKnownHostsFilePaths { get; }

Property Value

IReadOnlyList<string>

Remarks

This contains ~/.ssh/known_hosts.

DefaultWindowSize

Gets or sets the default SSH channel window size in bytes. Defaults to 2 MB (2,097,152 bytes).

public int DefaultWindowSize { get; set; }

Property Value

int

Remarks

The window size controls the maximum amount of data that can be sent by the remote end before it must wait for acknowledgement. Larger values can improve throughput on high-latency or high-bandwidth links at the cost of higher memory usage per channel.

EnableBatchModeWhenConsoleIsRedirected

Gets or sets whether to enable batch mode when console is redirected.

public bool EnableBatchModeWhenConsoleIsRedirected { get; set; }

Property Value

bool

Remarks

Defaults to true.

EncryptionAlgorithmsClientToServer

Gets or sets the permitted ciphers for client to server communication in order of preference.

public AlgorithmList EncryptionAlgorithmsClientToServer { get; set; }

Property Value

AlgorithmList

EncryptionAlgorithmsServerToClient

Gets or sets the permitted ciphers for server to client communication in order of preference.

public AlgorithmList EncryptionAlgorithmsServerToClient { get; set; }

Property Value

AlgorithmList

EnvironmentVariables

Gets or sets environment variables for all remote processes.

public Dictionary<string, string> EnvironmentVariables { get; set; }

Property Value

Dictionary<string, string>

ForwardAgent

Gets or sets whether to forward the SSH agent to the server.

public bool ForwardAgent { get; set; }

Property Value

bool

Remarks

Defaults to false.

When enabled, remote processes started through ExecuteAsync(string, CancellationToken) and related methods can use the keys of the local SSH agent to authenticate with other servers.

The agent channels opened by the server are proxied to the SSH agent identified by ForwardAgentAddress.

Enabling this gives users who can access the agent socket on the server (including the administrator) full control over the local agent for the duration of the connection. Besides using keys to authenticate, this includes operations that change the agent, like removing keys. Only enable this for servers that are trusted.

The server may refuse to forward the agent (OpenSSH: AllowAgentForwarding no). Then no agent channels are opened.

ForwardAgentAddress

Gets or sets the address of the SSH agent that is forwarded when ForwardAgent is enabled.

public string? ForwardAgentAddress { get; set; }

Property Value

string

Remarks

Defaults to null.

null and an empty string mean the default SSH agent is forwarded. That is the agent from the SSH_AUTH_SOCK environment variable, and on Windows the openssh-ssh-agent named pipe when that variable is not set.

This is set to the agent specified by the ForwardAgent ssh config option when that option includes an agent address.

ForwardX11

Gets or sets whether to forward X11 connections.

public ForwardMode ForwardX11 { get; set; }

Property Value

ForwardMode

Remarks

Defaults to Off. This can be overridden per remote process using ForwardX11.

When set to Request, X11 setup failures are logged and the remote process is started without X11 forwarding.

When set to Require, X11 setup failures fail the operation.

X11 forwarding should be enabled with caution. Users who can bypass file permissions on the remote host (for the user's X11 authorization database) can access the local X11 display through the forwarded connection. When ForwardX11Trusted is also enabled, an attacker may be able to perform activities such as keystroke monitoring.

ForwardX11Timeout

Gets or sets the timeout for untrusted X11 forwarding.

public TimeSpan ForwardX11Timeout { get; set; }

Property Value

TimeSpan

Remarks

Defaults to 20 minutes. X11 connections received after this time are refused. Zero disables the timeout.

This only applies when ForwardX11Trusted is false.

ForwardX11Trusted

Gets or sets whether to give remote X11 clients full access to the local X11 display.

public bool ForwardX11Trusted { get; set; }

Property Value

bool

Remarks

Defaults to false.

When true, the authentication data for the display is read from the Xauthority file (XAUTHORITY, or ~/.Xauthority). When there is no authentication data, fake authentication data is used, which may be accepted by X servers that don't require authentication.

When false, XAuthLocation is used to generate untrusted authentication data that is subject to X11 SECURITY extension restrictions.

GlobalKnownHostsFilePaths

Gets or sets the paths to global known hosts files.

public List<string> GlobalKnownHostsFilePaths { get; set; }

Property Value

List<string>

Remarks

HashKnownHosts

Gets or sets whether to hash hostnames in the known hosts file.

public bool HashKnownHosts { get; set; }

Property Value

bool

Remarks

Defaults to false. Hashing hostnames is no longer considered good practice.

HostAuthentication

Gets or sets the HostAuthentication delegate.

public HostAuthentication? HostAuthentication { get; set; }

Property Value

HostAuthentication

Remarks

This delegate is not called when the host key is known to be trusted or revoked.

HostName

Gets or sets the hostname or IP address of the server.

public string HostName { get; set; }

Property Value

string

KeepAliveCountMax

Gets or sets the maximum number of keep-alive messages before disconnecting.

public int KeepAliveCountMax { get; set; }

Property Value

int

Remarks

Defaults to 3.

KeepAliveInterval

Gets or sets the interval between keep-alive messages.

public TimeSpan KeepAliveInterval { get; set; }

Property Value

TimeSpan

Remarks

Defaults to Zero.

KeyExchangeAlgorithms

Gets or sets the permitted key exchange algorithms in order of preference.

public AlgorithmList KeyExchangeAlgorithms { get; set; }

Property Value

AlgorithmList

MacAlgorithmsClientToServer

Gets or sets the permitted integrity algorithms for client to server communication in order of preference.

public AlgorithmList MacAlgorithmsClientToServer { get; set; }

Property Value

AlgorithmList

MacAlgorithmsServerToClient

Gets or sets the permitted integrity algorithms for server to client communication in order of preference.

public AlgorithmList MacAlgorithmsServerToClient { get; set; }

Property Value

AlgorithmList

MinimumRSAKeySize

Gets or sets the minimum RSA key size accepted for authentication.

public int MinimumRSAKeySize { get; set; }

Property Value

int

Remarks

Defaults to 2048.

Port

Gets or sets the server port.

public int Port { get; set; }

Property Value

int

Remarks

Defaults to 22.

Proxy

Gets or sets the Proxy configuration for the connection.

public Proxy? Proxy { get; set; }

Property Value

Proxy

ServerHostKeyAlgorithms

Gets or sets the host key signature algorithms in order of preference.

public AlgorithmList ServerHostKeyAlgorithms { get; set; }

Property Value

AlgorithmList

ServerHostKeyCertificateAlgorithms

Gets or sets the permitted algorithms allowed for signing of certificates by certificate authorities (CAs).

public AlgorithmList ServerHostKeyCertificateAlgorithms { get; set; }

Property Value

AlgorithmList

Remarks

The client will not accept host certificates signed using algorithms other than those specified.

TcpKeepAlive

Gets or sets whether to enable TCP keep-alive.

public bool TcpKeepAlive { get; set; }

Property Value

bool

Remarks

Defaults to true.

UpdateKnownHostsFileAfterAuthentication

Gets or sets whether to update the known hosts file after authentication.

public bool UpdateKnownHostsFileAfterAuthentication { get; set; }

Property Value

bool

Remarks

Defaults to false.

UserKnownHostsFilePaths

Gets or sets the paths to user known hosts files.

public List<string> UserKnownHostsFilePaths { get; set; }

Property Value

List<string>

Remarks

UserName

Gets or sets the username.

public string UserName { get; set; }

Property Value

string

Remarks

Defaults to UserName.

X11Display

Gets or sets the local X11 display that X11 connections are forwarded to.

public string? X11Display { get; set; }

Property Value

string

Remarks

Defaults to null which means the DISPLAY environment variable is used.

XAuthLocation

Gets or sets the path of the xauth program.

public string XAuthLocation { get; set; }

Property Value

string

Remarks

Defaults to xauth which is looked up using PATH.

xauth is used to generate authentication data when ForwardX11Trusted is false.