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
destinationstringThe 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
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
Remarks
Defaults to false.
BannerHandler
Gets or sets the BannerHandler delegate.
public BannerHandler? BannerHandler { get; set; }
Property Value
Remarks
Defaults to a handler that logs the banner at Information level using Log().
Custom handlers can call Log() to log the banner.
Set to null to ignore banners.
BatchMode
Gets or sets whether to allow interactive prompts during callbacks. This affects the IsNonInteractive and IsNonInteractive properties.
[Obsolete("Use NonInteractive instead.")]
public bool BatchMode { get; set; }
Property Value
Remarks
Defaults to false.
When SetNonInteractiveWhenConsoleIsRedirected is true (the default), the connection is also non-interactive when the console is redirected.
Authentication callbacks also report non-interactive during implicit connects (including automatic reconnects) and key re-exchanges.
ClientKeyAlgorithms
Gets or sets the signature algorithms allowed for client key authentication.
public AlgorithmList? ClientKeyAlgorithms { get; set; }
Property Value
Remarks
This limits how Credentials can be used for authentication based on the key signature algorithms. When null, all supported algorithms are allowed.
CompressionAlgorithmsClientToServer
Gets or sets the permitted compression algorithms for client to server communication in order of preference.
public AlgorithmList CompressionAlgorithmsClientToServer { get; set; }
Property Value
Remarks
These algorithms are only used when EnableCompression is true.
CompressionAlgorithmsServerToClient
Gets or sets the permitted compression algorithms for server to client communication in order of preference.
public AlgorithmList CompressionAlgorithmsServerToClient { get; set; }
Property Value
Remarks
These algorithms are only used when EnableCompression is true.
ConnectTimeout
Gets or sets the connection timeout.
public TimeSpan ConnectTimeout { get; set; }
Property Value
Remarks
Defaults to 15 seconds.
Credentials
Gets or sets the credentials for authentication.
public List<Credential> Credentials { get; set; }
Property Value
Remarks
Defaults to DefaultCredentials.
DefaultCredentials
Gets the default Credential list used for authentication.
public static IReadOnlyList<Credential> DefaultCredentials { get; }
Property Value
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
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
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
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 disable interactive prompts when console is redirected.
[Obsolete("Use SetNonInteractiveWhenConsoleIsRedirected instead.")]
public bool EnableBatchModeWhenConsoleIsRedirected { get; set; }
Property Value
Remarks
Defaults to true.
EnableCompression
Gets or sets whether to use compression.
public bool EnableCompression { get; set; }
Property Value
EncryptionAlgorithmsClientToServer
Gets or sets the permitted ciphers for client to server communication in order of preference.
public AlgorithmList EncryptionAlgorithmsClientToServer { get; set; }
Property Value
EncryptionAlgorithmsServerToClient
Gets or sets the permitted ciphers for server to client communication in order of preference.
public AlgorithmList EncryptionAlgorithmsServerToClient { get; set; }
Property Value
EnvironmentVariables
Gets or sets environment variables for all remote processes.
public Dictionary<string, string> EnvironmentVariables { get; set; }
Property Value
ForwardAgent
Gets or sets whether to forward the SSH agent to the server.
public ForwardMode ForwardAgent { get; set; }
Property Value
Remarks
Defaults to Off.
When set to Request, agent forwarding setup failures (e.g., no agent available) are logged and the remote process is started without agent forwarding. When set to Require, the operation fails if setup fails or the server refuses agent forwarding.
Can be overridden per command using ForwardAgent.
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).
With Request, no agent channels are opened.
With Require, the operation fails.
ForwardAgentAddress
Gets or sets the address of the SSH agent that is forwarded when ForwardAgent is not Off.
public string? ForwardAgentAddress { get; set; }
Property Value
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
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
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
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
Remarks
Defaults to DefaultGlobalKnownHostsFilePaths.
HashKnownHosts
Gets or sets whether to hash hostnames in the known hosts file.
public bool HashKnownHosts { get; set; }
Property Value
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
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
KeepAliveCountMax
Gets or sets the maximum number of keep-alive messages before disconnecting.
public int KeepAliveCountMax { get; set; }
Property Value
Remarks
Defaults to 3.
KeepAliveInterval
Gets or sets the interval between keep-alive messages.
public TimeSpan KeepAliveInterval { get; set; }
Property Value
Remarks
Defaults to Zero.
KeyExchangeAlgorithms
Gets or sets the permitted key exchange algorithms in order of preference.
public AlgorithmList KeyExchangeAlgorithms { get; set; }
Property Value
MacAlgorithmsClientToServer
Gets or sets the permitted integrity algorithms for client to server communication in order of preference.
public AlgorithmList MacAlgorithmsClientToServer { get; set; }
Property Value
MacAlgorithmsServerToClient
Gets or sets the permitted integrity algorithms for server to client communication in order of preference.
public AlgorithmList MacAlgorithmsServerToClient { get; set; }
Property Value
MinimumRSAKeySize
Gets or sets the minimum RSA key size accepted for authentication.
public int MinimumRSAKeySize { get; set; }
Property Value
Remarks
Defaults to 2048.
NonInteractive
Gets or sets whether to allow interactive prompts during callbacks. This affects the IsNonInteractive and IsNonInteractive properties.
public bool NonInteractive { get; set; }
Property Value
Remarks
Defaults to false.
When SetNonInteractiveWhenConsoleIsRedirected is true (the default), the connection is also non-interactive when the console is redirected.
Authentication callbacks also report non-interactive during implicit connects (including automatic reconnects) and key re-exchanges.
Port
Gets or sets the server port.
public int Port { get; set; }
Property Value
Remarks
Defaults to 22.
Proxy
Gets or sets the Proxy configuration for the connection.
public Proxy? Proxy { get; set; }
Property Value
ServerHostKeyAlgorithms
Gets or sets the host key signature algorithms in order of preference.
public AlgorithmList ServerHostKeyAlgorithms { get; set; }
Property Value
ServerHostKeyCertificateAlgorithms
Gets or sets the permitted algorithms allowed for signing of certificates by certificate authorities (CAs).
public AlgorithmList ServerHostKeyCertificateAlgorithms { get; set; }
Property Value
Remarks
The client will not accept host certificates signed using algorithms other than those specified.
SetNonInteractiveWhenConsoleIsRedirected
Gets or sets whether to disable interactive prompts when console is redirected.
public bool SetNonInteractiveWhenConsoleIsRedirected { get; set; }
Property Value
Remarks
Defaults to true.
TcpKeepAlive
Gets or sets whether to enable TCP keep-alive.
public bool TcpKeepAlive { get; set; }
Property Value
Remarks
Defaults to true.
UpdateKnownHostsFileAfterAuthentication
Gets or sets whether to update the known hosts file after authentication.
public bool UpdateKnownHostsFileAfterAuthentication { get; set; }
Property Value
Remarks
Defaults to false.
UserKnownHostsFilePaths
Gets or sets the paths to user known hosts files.
public List<string> UserKnownHostsFilePaths { get; set; }
Property Value
Remarks
Defaults to DefaultUserKnownHostsFilePaths.
UserName
Gets or sets the username.
public string UserName { get; set; }
Property Value
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
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
Remarks
Defaults to xauth which is looked up using PATH.
xauth is used to generate authentication data when ForwardX11Trusted is false.