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 aProxyCommandor 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 yesforwards.
- AllowKnownHostsCommand
Whether a configured
KnownHostsCommandmay be run (a local shell command whose output is trusted as known_hosts lines). Default false: unlikeProxyCommand, 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
ProxyCommandmay be run (it is a local shell command, as in OpenSSH). Default true.
- AskHostKey
Answers
StrictHostKeyChecking askfor an unknown host key (see AskHostKey). Not called inBatchMode.
- 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
BatchModeor for a ProxyJump hop.
- Compression
Overrides ssh_config's
Compressionfor the destination, asssh -Cdoes (see Compression). ProxyJump hops keep their own configuration'sCompression: 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 saysno, andIPQoS), so what it sets wins. Not called with aProxyCommandor 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 fromConnectAsyncas it is.
- ConfirmAddKeyToAgent
Answers
AddKeysToAgent ask: called for each identity-file key the server accepted, before it goes to the agent, as ssh asks throughSSH_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 inBatchMode,askadds nothing, as ssh does when it cannot ask. Called after the connection is made; the caller's token, notConnectTimeout, bounds it. What it throws closes the new connection and is thrown fromConnectAsync.
- ConfirmHostKeyUpdate
Confirms known_hosts changes under
UpdateHostKeys ask(see ConfirmHostKeyUpdate). Without it,askleaves known_hosts alone. Not called inBatchMode.
- ConnectTimeout
Overrides ssh_config's
ConnectTimeoutfor 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
ConnectionAttemptsfor 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 theConnectTimeoutbounds 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 everyProxyJumphop 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
ServerAliveCountMaxfor the destination and every ProxyJump hop (see KeepAliveCountMax). Null (the default) leaves it to ssh_config (3 when unset).
- KeepAliveInterval
Overrides ssh_config's
ServerAliveIntervalfor 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, withKbdInteractiveAuthentication 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 inBatchMode. Without it, encrypted identity files are skipped.
- Password
The destination's password, sent with the
passwordmethod unlessPasswordAuthenticationisno, or through keyboard-interactive (see Password) unlessKbdInteractiveAuthenticationisno. 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
NumberOfPasswordPromptstimes (default 3); see PasswordProvider. Not called inBatchMode, when bothPasswordAuthenticationandKbdInteractiveAuthenticationareno, or for a ProxyJump hop.
- Port
The destination's port, overriding ssh_config's
Portasssh -pdoes: resolution sees it too (%p, and the port aMatchblock and the result report). A port in anssh://host:portdestination 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 ownIdentityFile, 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 execrunner, ...). 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
ProxyCommandor a Proxy, which make the connection. Null (the default) tries them in order.
- StartForwardings
Start the destination's
LocalForward,RemoteForwardandDynamicForwardforwardings 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,ExitOnForwardFailureandClearAllForwardingsapply.
- UseAgent
Whether to offer the SSH agent's keys, as ssh does: the agent named by
IdentityAgent, or FromEnvironment(). WithIdentitiesOnly yes, only agent keys that match anIdentityFileare offered. Default true.