Table of Contents

Class SshConfigConnectOptions

Namespace
SshSharp
Assembly
SshSharp.dll

Options for ConnectAsync(string, SshConfigConnectOptions?, CancellationToken), which takes everything else from ssh_config: host name, port, user, identity files, known_hosts and StrictHostKeyChecking, algorithms, ProxyJump, ProxyCommand, ServerAliveInterval, ConnectTimeout, ConnectionAttempts and AddressFamily. A few of these can be set here instead, overriding what the configuration says: Port, ConnectTimeout, ConnectionAttempts, AddressFamily, KeepAliveInterval, KeepAliveCountMax and Compression, as HostKeyVerifier and Proxy do for host key checking and the first network hop.

public sealed class SshConfigConnectOptions
Inheritance
SshConfigConnectOptions
Inherited Members

Properties

AddressFamily

Overrides ssh_config's AddressFamily: which of the server's addresses are tried (see AddressFamily). It applies to the first network connection, the only one this machine makes: to the destination, or to the first ProxyJump hop. Not with a ProxyCommand or a Proxy, which make the connection. Null (the default) leaves it to ssh_config.

Agent

The agent to use instead of the configured or environment one: another agent's path, or an in-process one (FromKeys(params SshPrivateKey[])). It is also the agent ForwardAgent yes forwards.

AllowKnownHostsCommand

Whether a configured KnownHostsCommand may be run (a local shell command whose output is trusted as known_hosts lines). Default false: unlike ProxyCommand, which only carries the connection, this one decides which host keys are trusted, so a configuration the application does not control must not be able to supply them. Off, a configuration that names one fails the connection rather than silently checking fewer keys than it says.

AllowProxyCommand

Whether a configured ProxyCommand may be run (it is a local shell command, as in OpenSSH). Default true.

AskHostKey

Answers StrictHostKeyChecking ask for an unknown host key (see AskHostKey). Not called in BatchMode.

AuthenticationBanner

Receives the server's pre-authentication banner (see AuthenticationBanner).

ChangePassword

Answers the destination's request to change an expired password (see ChangePassword). Not called in BatchMode or for a ProxyJump hop.

Compression

Overrides ssh_config's Compression for the destination, as ssh -C does (see Compression). ProxyJump hops keep their own configuration's Compression: what they carry for the destination is already encrypted, which does not compress. Null (the default) leaves it to ssh_config (off when unset).

Config

The configuration to resolve against. Default: the user's and the system's files (LoadDefault(string?)).

ConfigureSocket

Sets socket options on the TCP connection this machine makes: to the destination, or to the first ProxyJump hop (see ConfigureSocket). It runs after the settings ssh_config gives the socket (TCPKeepAlive, on unless the configuration says no, and IPQoS), so what it sets wins. Not called with a ProxyCommand or a Proxy, which make the connection; hosts reached through a ProxyJump hop are tunnels, with no socket of their own. What it throws ends the attempt and is thrown from ConnectAsync as it is.

ConfirmAddKeyToAgent

Answers AddKeysToAgent ask: called for each identity-file key the server accepted, before it goes to the agent, as ssh asks through SSH_ASKPASS ("Add key ... to agent?"). Complete with true to add it (with no lifetime or confirmation constraint, as ssh adds it), false to leave it out. Without it, or in BatchMode, ask adds nothing, as ssh does when it cannot ask. Called after the connection is made; the caller's token, not ConnectTimeout, bounds it. What it throws closes the new connection and is thrown from ConnectAsync.

ConfirmHostKeyUpdate

Confirms known_hosts changes under UpdateHostKeys ask (see ConfirmHostKeyUpdate). Without it, ask leaves known_hosts alone. Not called in BatchMode.

ConnectTimeout

Overrides ssh_config's ConnectTimeout for the destination and every ProxyJump hop: how long each may take, from loading its identity files through authentication (see ConnectTimeout). A hop's time counts toward the host it leads to. InfiniteTimeSpan sets no limit whatever the configuration says; null (the default) leaves it to ssh_config.

ConnectionAttempts

Overrides ssh_config's ConnectionAttempts for the destination and every ProxyJump hop: how many times to try the TCP connection (to the server, or to Proxy), one second apart. Only failures to reach it are tried again (refused, unreachable, timed out), never a failed handshake or authentication, and the ConnectTimeout bounds all the attempts together. Null (the default) leaves it to ssh_config (1 when unset).

ForwardAgentFilter

Decides what programs on the server may do with the forwarded agent (ForwardAgent yes), for the destination and every ProxyJump hop that forwards it; see ForwardAgentFilter.

HostKeyVerifier

Replaces the default host key verification, which is a KnownHostsVerifier built from the host's configuration (UserKnownHostsFile, GlobalKnownHostsFile, StrictHostKeyChecking, HashKnownHosts).

KeepAliveCountMax

Overrides ssh_config's ServerAliveCountMax for the destination and every ProxyJump hop (see KeepAliveCountMax). Null (the default) leaves it to ssh_config (3 when unset).

KeepAliveInterval

Overrides ssh_config's ServerAliveInterval for the destination and every ProxyJump hop (see KeepAliveInterval). Zero and InfiniteTimeSpan send no keep-alives whatever the configuration says; null (the default) leaves it to ssh_config.

KeyboardInteractive

Answers the destination's keyboard-interactive authentication (see KeyboardInteractive). Not called in BatchMode, with KbdInteractiveAuthentication no, or for a ProxyJump hop.

Logger

Receives diagnostics for this connection and every jump host.

PassphraseProvider

Asked for the passphrase of an encrypted IdentityFile (the argument is the file's path). Return null to skip that key. Not called in BatchMode. Without it, encrypted identity files are skipped.

Password

The destination's password, sent with the password method unless PasswordAuthentication is no, or through keyboard-interactive (see Password) unless KbdInteractiveAuthentication is no. Never offered to a ProxyJump hop, which logs in with keys or the agent.

PasswordProvider

Asks for the destination's password when authentication reaches it, at most NumberOfPasswordPrompts times (default 3); see PasswordProvider. Not called in BatchMode, when both PasswordAuthentication and KbdInteractiveAuthentication are no, or for a ProxyJump hop.

Port

The destination's port, overriding ssh_config's Port as ssh -p does: resolution sees it too (%p, and the port a Match block and the result report). A port in an ssh://host:port destination wins. Not used for ProxyJump hops, whose ports come from their own entries and configuration. Null (the default) leaves it to ssh_config (22 when unset).

PrivateKeys

Keys to offer the destination before its configured IdentityFiles. The client does not dispose them. Never offered to a ProxyJump hop, which logs in with its own configuration's identity files and the agent, as Password is never sent to one. (Before 1.1 they were offered to every hop too: a hop that needs one of these keys now needs it in its own IdentityFile, or in the agent.)

Proxy

An HTTP or SOCKS proxy for the first network hop: the destination, or the first ProxyJump host (later hops are reached through SSH). Not used for a host with a ProxyCommand, which makes its own connection.

ResolveOptions

Inputs for resolution (home directory, environment, Match exec runner, ...). Default: the current process's.

StaggeredConnectDelay

Races the addresses of the first network connection this machine makes, to the destination or to the first ProxyJump hop, RFC 8305 style (see StaggeredConnectDelay): the next address is tried once the one before has had this long or has failed. ssh_config has no directive for it; ssh tries the addresses in order. Not with a ProxyCommand or a Proxy, which make the connection. Null (the default) tries them in order.

StartForwardings

Start the destination's LocalForward, RemoteForward and DynamicForward forwardings once connected, as ssh does (see LocalForwardings and its siblings). Off by default: forwardings open listening ports, which a library should not do unasked. GatewayPorts, ExitOnForwardFailure and ClearAllForwardings apply.

UseAgent

Whether to offer the SSH agent's keys, as ssh does: the agent named by IdentityAgent, or FromEnvironment(). With IdentitiesOnly yes, only agent keys that match an IdentityFile are offered. Default true.