Features
Everything SshSharp does, one row per feature, with the API or ssh_config directive to use and the page that shows how.
1.1, 1.2 and 1.3 mark a feature added in that release.
OpenSSH compatibility lists what behaves as ssh does and what differs.
The four packages share one version: SshSharp (the client), SshSharp.Extensions.DependencyInjection,
SshSharp.IO.Abstractions and SshSharp.FileProviders. All target .NET 8, .NET 10 and .NET 11 1.2 and have no native dependencies.
Connecting and configuration
| Feature | What it does | API / ssh_config |
Docs |
|---|---|---|---|
| Connect by alias | Resolves a destination as ssh -G does: host name, port, user, keys, agent, jump hosts and host key policy |
SshClient.ConnectAsync("alias"); ~/.ssh/config |
ssh_config and known_hosts |
ssh_config |
Host, Match (localnetwork, sessiontype, command, tagged, and exec when you allow it), Include, tokens and environment variables |
SshConfig.Load, SshConfigConnectOptions, SshConfigResolveOptions |
Directives |
| Typed options in code | Connect without ssh_config: host, credentials, host key policy and every setting as a typed property |
SshClientOptions | Getting started |
| Override the configuration | Change the port, timeouts, attempts, address family, keep-alives or compression of an alias in code 1.1 | SshConfigConnectOptions.Port, ConnectTimeout, ConnectionAttempts, ... |
ssh_config and known_hosts |
| Host name canonicalization | CanonicalizeHostname with a DNS resolver built in, or your own 1.1 |
SshConfigResolveOptions.UseDnsCanonicalizer, HostCanonicalizer |
Configuration files |
Jump hosts from ssh_config |
ProxyJump chains of any length, each hop with its own configuration |
ProxyJump |
Jump hosts |
| Jump hosts in code | One SshJumpHost per hop, each with its own credentials and host key check; the destination's credentials never reach a hop 1.1 |
SshClientOptions.JumpHosts |
Jump hosts |
ProxyCommand |
Runs a local command and speaks SSH over its standard input and output (an opt-in) | ProxyCommand; SshConfigConnectOptions.AllowProxyCommand |
Connecting |
| HTTP and SOCKS proxies | Reach the server through an HTTP CONNECT, SOCKS 4/4a or SOCKS 5 proxy, with credentials |
SshProxy.Http, Socks5, Socks4, FromUri |
Connecting |
| Your own transport | A function that returns a connected stream (a cloud tunnel, a WebSocket, a named pipe), usable wherever a proxy is 1.1 | SshProxy.FromConnector |
Jump hosts |
| Connect over a stream | Run SSH over any Stream you already have |
SshClient.ConnectAsync(stream, ...) |
Connecting |
| Timeouts | One limit for the TCP connection, key exchange and authentication together 1.1 | SshClientOptions.ConnectTimeout; ConnectTimeout |
Cancellation and timeouts |
| Connection attempts | Retries a server that cannot be reached, one second apart, within ConnectTimeout 1.1 |
SshClientOptions.ConnectionAttempts; ConnectionAttempts |
Cancellation and timeouts |
| Address family and local address | IPv4 or IPv6 only 1.1; connect from a chosen address or interface | AddressFamily, LocalEndPoint; AddressFamily, BindAddress, BindInterface |
Connecting |
| Staggered connect | Races the server's addresses, IPv6 and IPv4 taking turns, as RFC 8305 ("Happy Eyeballs") describes, so an address that does not answer costs a short delay (an opt-in) 1.2 | SshClientOptions.StaggeredConnectDelay, SshConfigConnectOptions.StaggeredConnectDelay |
Connecting |
| Socket options | Set options on each TCP socket before it connects; TCPKeepAlive and IPQoS applied 1.1 |
SshClientOptions.ConfigureSocket; TCPKeepAlive, IPQoS |
Tune and inspect a connection |
| Channel window and packet size | Larger windows for long, fast links (default 2 MiB window, 32 KiB packets) 1.1 | ChannelWindowSize, ChannelMaxPacketSize |
Tune for throughput |
| Identification comment | Adds a comment to the client's identification line 1.1 | SshClientOptions.VersionAddendum |
Tune and inspect a connection |
| Connection details | Endpoints, connect time, session ID, bytes sent and received, the negotiated algorithms 1.1 | RemoteEndPoint, LocalEndPoint, ConnectedAt, SessionId, BytesSent, BytesReceived, Algorithms |
Tune and inspect a connection |
| Re-keying | Automatic by data and time, or on demand 1.1 | RekeyAfterBytes, RekeyAfterTime, SshClient.RekeyAsync |
Tune and inspect a connection |
| Keep-alive | Detects a dead or stalled server, also while a write is blocked | KeepAliveInterval, KeepAliveCountMax; ServerAliveInterval, ServerAliveCountMax |
Keep-alive and reconnecting |
| Round-trip ping | Measures the round trip on an open connection | SshClient.PingAsync |
Keep-alive and reconnecting |
| Connection state | Learn when the connection drops, and why | IsConnected, ConnectionClosed, ConnectionError |
Keep-alive and reconnecting |
Host verification
| Feature | What it does | API / ssh_config |
Docs |
|---|---|---|---|
known_hosts |
Hashed hosts, @cert-authority, @revoked, and the StrictHostKeyChecking policies; new keys recorded as ssh records them; a port-less @revoked line applies on every port, and a changed key let through by No gets no password, agent or forwarding, as in ssh 1.2 |
KnownHostsVerifier; UserKnownHostsFile, StrictHostKeyChecking, HashKnownHosts |
Verify host keys |
| Pinned keys | Accept only the fingerprints or public keys you name | SshHostKeyVerifier.Pinned (fingerprints, or SshPublicKey 1.1) |
Verify host keys |
| Your own rule | Decide each host key in code | SshHostKeyVerifier.FromDelegate |
Verify host keys |
| Host certificates | Trust host keys signed by a certificate authority; only from authorities that sign with the algorithms you allow; one that cannot be used falls back to the plain key, as in ssh 1.2 |
@cert-authority lines; SshClientOptions.CASignatureAlgorithms, CASignatureAlgorithms |
Host keys |
| Revoked host keys | OpenSSH KRLs and key lists | KnownHostsVerifier.RevokedHostKeys; RevokedHostKeys |
Host keys |
| Host key rotation | Learns the server's other host keys (hostkeys-00@openssh.com), and leaves known_hosts alone in the same cases as ssh 1.2 |
KnownHostsVerifier.UpdateHostKeys; UpdateHostKeys |
Host keys |
KnownHostsCommand |
Gets known hosts from a command (an opt-in) | KnownHostsCommand; AllowKnownHostsCommand |
Directives |
| Host key scanning | Fetches a server's host keys without logging in, as ssh-keyscan |
SshClient.ScanHostKeysAsync |
Verify host keys |
Authentication and keys
| Feature | What it does | API / ssh_config |
Docs |
|---|---|---|---|
| Public keys | Ed25519, ECDSA and RSA (SHA-2 signatures), encrypted or not; certificates paired with their keys | SshClientOptions.PrivateKeys, SshPrivateKey.LoadAsync; IdentityFile, CertificateFile |
Keys and the SSH agent |
| Key formats | Reads OpenSSH, PKCS#1, PKCS#8, SEC1 and PuTTY .ppk, each also encrypted (traditional Proc-Type: 4,ENCRYPTED PEM with AES; OpenSSH keys with every ssh-keygen -Z cipher, chacha20-poly1305@openssh.com included) 1.2 |
SshPrivateKey.Parse, LoadAsync |
Encrypted key files |
| Key generation | Ed25519, ECDSA and RSA keys, saved as ssh-keygen saves them |
SshPrivateKey.Generate, SaveAsync |
Authentication |
| Key export | PKCS#8 and PuTTY .ppk v3, and OpenSSH with your own bcrypt rounds 1.1 |
ToPkcs8PrivateKey, ToPuttyPrivateKey, SaveAsync(path, SshPrivateKeyFormat, ...) |
Keys and the SSH agent |
| Public keys as a type | Parse .pub and authorized_keys lines, take fingerprints, verify signatures 1.1 |
SshPublicKey | Keys and the SSH agent |
| Keys you cannot export | Sign with a key in a KMS, an HSM, a TPM or the Windows key store | SshKeySigner, SshPrivateKey.FromSigner |
Keys and the SSH agent |
| Passwords | A given password, or a callback asked only when one is needed, up to NumberOfPasswordPrompts times 1.1 |
Password, PasswordProvider 1.1; NumberOfPasswordPrompts |
Passwords, prompts and expiry |
| Expired passwords | Answers the server's request to change an expired password (RFC 4252 section 8) 1.1 | SshClientOptions.ChangePassword |
Passwords, prompts and expiry |
| Keyboard-interactive and multi-factor | One-time codes and PAM prompts; the server's multi-factor chains followed | SshClientOptions.KeyboardInteractive |
Authentication |
| What was tried | Each method tried, with its key fingerprint and outcome, when nothing logs in 1.1 | SshAuthenticationException.Attempts |
Passwords, prompts and expiry |
| Method order and key types | The authentication order, the RSA size floor and the key algorithms offered 1.1 | PreferredAuthentications, RequiredRsaSize, PubkeyAcceptedAlgorithms |
Choose algorithms and authentication |
| SSH agent | ssh-agent, the Windows OpenSSH agent and PuTTY's Pageant; FIDO security keys held by the agent |
SshAgent.FromEnvironment, FromPageant; IdentityAgent |
Keys and the SSH agent |
| Agent key management | Add with a lifetime, confirmation or destination limits, remove, lock; AddKeysToAgent (with ask 1.1) |
AddKeyAsync, SshAgentKeyConstraints, RemoveKeyAsync, LockAsync; AddKeysToAgent |
Keys and the SSH agent |
| Agent forwarding | Lets programs on the server use your agent | SshClientOptions.ForwardAgent; ForwardAgent |
Keys and the SSH agent |
| In-process agent | An agent in your process from any keys SshSharp holds, KMS signers included, to log in with and to forward 1.1 | SshAgent.FromKeys |
Keys and the SSH agent |
| Forwarded-agent filter | Decides each request a forwarded agent gets: which keys are listed, what may be signed 1.1 | SshClientOptions.ForwardAgentFilter |
Keys and the SSH agent |
| User certificates | Log in with an OpenSSH certificate | SshPrivateKey.WithCertificate; CertificateFile |
Certificates |
| Issue certificates | Sign user and host certificates as a CA, with the CA key in a file, an agent or a KMS 1.1 | SshCertificateBuilder | Certificates |
| Check certificates | Signature, validity period, principal and authority, as sshd checks them 1.1; a certificate with more than 256 principals, or with its options or extensions out of order, refused as malformed (draft-ietf-sshm-cert) 1.3 |
SshCertificate.VerifySignature, IsValidAt, IsValidFor |
Certificates |
| Revocation lists | Checks keys and certificates against an OpenSSH KRL or a key list, as ssh-keygen -Q 1.1 |
SshKeyRevocationList | Certificates |
| Kerberos | gssapi-with-mic with the current user's ticket or given credentials (.NET 10 and later) |
SshClientOptions.Gssapi; GSSAPIAuthentication, GSSAPIDelegateCredentials |
Kerberos |
| SSH signatures | Sign and verify files and git commits, with allowed-signers files, as ssh-keygen -Y |
SshSignature, SshAllowedSigners |
Signing files and commits |
Sessions and commands
| Feature | What it does | API / ssh_config |
Docs |
|---|---|---|---|
| Run a command | Collects the output and exit status; EnsureSuccess throws on failure 1.1 |
RunCommandAsync, SshCommandResult.EnsureSuccess |
Run a command |
| Input and options for a command | Standard input from bytes, text or a stream, with session options 1.1 | RunCommandAsync(command, options, SshCommandInput, ...) |
Run a command |
| Stream a command | Standard input, output and error as streams, for large or endless output | StartCommandAsync, SshSession |
Stream large output |
| Shells and terminals | An interactive shell with a pseudo-terminal, window resizing and terminal modes | StartShellAsync, SshTerminalOptions, ResizeTerminalAsync |
Interactive shells |
expect-style scripting |
Wait for prompts and patterns, send lines | SshExpect | Interactive shells |
| Environment variables | env requests for a session |
SshSessionOptions.Environment; SetEnv, SendEnv |
Commands and shells |
| Signals and BREAK | Any signal, including extension signals; BREAK for serial consoles (RFC 4335) | SendSignalAsync, SendBreakAsync |
Commands and shells |
| Subsystems | Any subsystem, as ssh -s (for example netconf) |
StartSubsystemAsync |
Commands and shells |
| Channel idle timeouts | Closes idle channels by type, as OpenSSH 9.2+ | ChannelTimeouts; ChannelTimeout |
Directives |
| Keystroke timing | Hides keystroke timing in terminal sessions, as OpenSSH 9.5+ | ObscureKeystrokeTiming |
Directives |
| No more sessions | Refuses further sessions on a connection (no-more-sessions@openssh.com) |
SshClient.PreventNewSessionsAsync |
Commands and shells |
SFTP
| Feature | What it does | API | Docs |
|---|---|---|---|
| File transfers | Pipelined uploads and downloads (64 requests in flight by default), with progress, kept times and permissions, and resume | UploadFileAsync, DownloadFileAsync, UploadAsync, DownloadAsync; SftpTransferOptions |
Transfer files with SFTP |
| Segmented transfers | One large file in parallel ranges over several sessions, downloads and (since 1.1) uploads 1.1 | SftpTransferOptions.Segments |
SFTP |
| Directory trees | Whole trees either way, several files at once 1.1 | UploadDirectoryAsync, DownloadDirectoryAsync; MaxConcurrentFiles |
Transfer files with SFTP |
| Filters and skipping unchanged files | Choose what a directory transfer includes; skip files whose size and time match, as rsync does 1.1, within a time tolerance for coarse file systems such as FAT 1.2 | SftpTransferOptions.Filter, SkipUnchanged, TimeTolerance |
Transfer files with SFTP |
| Unreadable directories | Directory transfers and recursive listings go past the subdirectories this user may not read, and report them, instead of failing 1.2 | SftpTransferOptions.SkipUnreadableDirectories, SftpListOptions.SkipUnreadableDirectories |
Transfer files with SFTP |
| Listings | Pipelined directory reads; name patterns and recursion 1.1; patterns that ignore case 1.2 | ListDirectoryAsync, SftpListOptions |
Transfer files with SFTP |
| Conveniences | mkdir -p, rm -r (never following links), whole-file reads and writes 1.1 |
CreateDirectoryAsync(path, createParents: true), DeleteDirectoryAsync(path, recursive: true), ReadAllTextAsync, WriteAllBytesAsync, ... |
Transfer files with SFTP |
| Files and links | Attributes, rename (with an atomic overwrite), symbolic and hard links, server-side copies, file system statistics | GetAttributesAsync, RenameAsync, CreateSymbolicLinkAsync, CreateHardLinkAsync, CopyFileAsync, GetFileSystemInfoAsync |
SFTP |
| Remote file streams | Seekable streams; writes behind (up to 16 in flight), errors never lost 1.1; fsync on flush |
OpenAsync, OpenReadAsync, OpenWriteAsync |
SFTP |
| Server-side hashes | Check a transfer with a hash the server computes (check-file, md5-hash) 1.1 |
GetFileHashAsync, SupportsFileHash |
SFTP |
| Vendor extensions | Send any extended request and read its reply 1.1 | SendExtendedRequestAsync |
SFTP |
| Timeouts | Fails requests once the server has been silent too long (off by default) 1.1 | SftpClient.OperationTimeout, IsConnected |
Cancellation and timeouts |
SCP
| Feature | What it does | API | Docs |
|---|---|---|---|
| Files, streams and directories | Uploads and downloads with progress and kept times, for servers without SFTP | UploadFileAsync, DownloadFileAsync, UploadDirectoryAsync, DownloadDirectoryAsync (SshSharp.Scp), SshScpOptions |
Transfer files with SCP |
| Path quoting for devices and Windows | Remote paths unquoted for network devices (Cisco IOS, MikroTik), or double-quoted for OpenSSH for Windows with cmd.exe; unsafe paths refused before sending 1.3 |
SshScpOptions.PathQuoting, SshScpPathQuoting |
Transfer files with SCP |
| Hostile-server checks | A server cannot write outside the target or slip in extra files | built in | File transfer (SCP) |
Forwarding and tunnels
| Feature | What it does | API / ssh_config |
Docs |
|---|---|---|---|
| Local forwarding | ssh -L: a local port to a host and port the server reaches |
ForwardLocalPortAsync; LocalForward |
Port forwarding |
| Remote forwarding | ssh -R: a port on the server to a host and port here |
ForwardRemotePortAsync; RemoteForward |
Port forwarding |
| Remote forwarding to a handler | Each connection to the server's port reaches your code as a Stream, with half-close and a shutdown grace period 1.1 |
ForwardRemotePortAsync(bindAddress, port, handler), HandlerShutdownTimeout |
Port forwarding |
| Dynamic forwarding | ssh -D: a SOCKS 4/5 proxy here |
ForwardDynamicPortAsync; DynamicForward |
Port forwarding |
| SOCKS 5 with a password | A dynamic forward that asks for a user name and password (RFC 1929), so it can serve other machines 1.1 | ForwardDynamicPortAsync(localEndPoint, credentials) |
Port forwarding |
| Remote dynamic forwarding | ssh -R port: a SOCKS proxy on the server's side, with a destination filter |
ForwardRemoteDynamicPortAsync; RemoteForward, PermitRemoteOpen 1.1 |
Port forwarding |
| Unix sockets in local forwarding | -L port:/remote.sock, -L /local.sock:host:port, -L /local.sock:/remote.sock; owner-only socket files 1.1 |
ForwardLocalPortAsync(endPoint, remoteSocketPath), ForwardLocalUnixSocketAsync; StreamLocalBindMask, StreamLocalBindUnlink |
Port forwarding |
| Remote Unix-socket forwarding | ssh -R /remote.sock:target, for example gpg-agent forwarding |
ForwardRemoteUnixSocketAsync |
Port forwarding |
| Tunnels without a listener | A Stream to a host and port, or a Unix socket, on the server's side |
OpenTcpTunnelAsync, OpenUnixSocketTunnelAsync |
Port forwarding |
HttpClient through SSH |
HTTP requests that connect through the SSH connection | CreateHttpConnectCallback; UseSshTunnel 1.1 |
Port forwarding |
Forwardings from ssh_config |
LocalForward, RemoteForward and DynamicForward started with the connection |
SshConfigConnectOptions.StartForwardings |
ssh_config and known_hosts |
| Vendor channels and global requests | Open a channel of any type and send a global request of any name, for what the server defines and SshSharp has no API for; half-close on the channel 1.3 | OpenChannelAsync, SshCustomChannel, SendGlobalRequestAsync |
Vendor channels and global requests |
Cryptography
| Feature | What it does | API / ssh_config |
Docs |
|---|---|---|---|
| Post-quantum key exchange | mlkem768x25519-sha256 (.NET 10 with platform ML-KEM) and sntrup761x25519-sha512 (managed, everywhere) |
defaults | Algorithms |
| Modern algorithms only | Curve25519, ECDH, SHA-2 finite-field DH (group exchange and group 18 1.1); ChaCha20-Poly1305, AES-GCM, AES-CTR with HMAC-SHA2 (plain hmac-sha2-* 1.1); Ed25519, ECDSA, RSA with SHA-2. No CBC, SHA-1 or ssh-rsa |
defaults | Algorithms |
| Algorithm choices in code | Key exchange, host key, cipher and MAC lists with ssh_config's +, - and ^ forms; unknown names fail when set 1.1 |
KexAlgorithms, HostKeyAlgorithms, Ciphers, Macs (SshAlgorithmList) |
Choose algorithms |
| Strict key exchange | The Terrapin countermeasure, always on | built in | Algorithms |
| FIPS mode | FIPS-approved algorithms only, including post-quantum mlkem768nistp256-sha256 and mlkem1024nistp384-sha384 on .NET 10 and later |
SshClientOptions.FipsMode |
FIPS mode |
| Delayed compression | zlib@openssh.com, started after authentication, off by default as in ssh 1.1 |
SshClientOptions.Compression; Compression |
Tune and inspect a connection |
.NET integration
| Feature | What it does | API | Docs |
|---|---|---|---|
| Dependency injection | Named endpoints from configuration, a factory for new connections, a shared connection that reconnects, and a health check | AddSshClient, ISshClientFactory, ISshConnectionProvider; AddSsh on IHealthChecksBuilder |
Dependency injection |
| Endpoint settings | Pinned host keys, private keys as values, a proxy URI, jump hosts, the agent, address family and compression from configuration 1.1 | SshEndpointOptions |
Dependency injection |
| Keyed endpoints | Inject one endpoint by name 1.1 | [FromKeyedServices("name")] ISshEndpoint |
ASP.NET Core and DI |
HttpClient through an endpoint |
A named HttpClient that connects through a named SSH connection 1.1 |
IHttpClientBuilder.UseSshTunnel |
ASP.NET Core and DI |
| Connection events | Connected, Disconnected and Reconnected, as a stream 1.1 | ISshConnectionProvider.WatchAsync |
Dependency injection |
IFileSystem over SFTP |
System.IO.Abstractions' File, Directory, Path and streams on the server; follows a reconnecting connection 1.1; hard links on .NET 11 (File.CreateHardLink, FileInfo.CreateAsHardLink, with hardlink@openssh.com) 1.3 |
SftpFileSystem (SshSharp.IO.Abstractions) |
IFileSystem and IFileProvider |
IFileProvider over SFTP |
A remote directory for ASP.NET Core static files, Razor views and configuration; follows a reconnecting connection 1.1 | SftpFileProvider (SshSharp.FileProviders) |
IFileSystem and IFileProvider |
| Native AOT and trimming | AOT-compatible, with an AOT-compiled smoke test against a real server in CI | IsAotCompatible |
Native AOT |
| Async and cancellation | Every network operation is async and takes a CancellationToken |
throughout | Cancellation and timeouts |
| Testable code | A small interface of your own in front of SshSharp, so your logic is tested without a server | your own seam | Unit-test code that uses SshSharp |
Observability
| Feature | What it does | API | Docs |
|---|---|---|---|
| Logging | ILogger events; never host names, user names, passwords or key material; the entries a server can trigger repeatedly are limited to 8 a minute per connection, the rest at Debug with a summary 1.3 |
SshClientOptions.Logger |
Logging and diagnostics |
| Traces | ActivitySource spans for connecting (SshSharp.Connect, with SshSharp.Authenticate inside it 1.2), running commands (SshSharp.Command) and SFTP and SCP 1.2 transfers (SshSharp.Sftp.*, SshSharp.Scp.*), following OpenTelemetry's conventions |
SshTelemetry.SourceName ("SshSharp") |
Errors and diagnostics |
| Metrics | Meter instruments: open connections and channels, connect duration, bytes sent and received, key exchanges, commands, SFTP and SCP file data, forwarded connections, keep-alive round trips, the shared connection's reconnections 1.2 |
SshTelemetry.SourceName |
Errors and diagnostics |
| Errors | One exception type with a machine-readable reason | SshException.Reason (SshFailureReason) |
Errors and failure reasons |