SshSharp
A managed, async-first SSH client library for .NET 8, .NET 10 and .NET 11. It reads ssh_config and
known_hosts the way OpenSSH does, so your application connects the way ssh would:
same host names, keys, agent, jump hosts and host key policy.
Install and connect
dotnet add package SshSharp
using SshSharp;
// An alias from ~/.ssh/config: host name, user, keys, agent, ProxyJump and known_hosts all come from there.
await using var client = await SshClient.ConnectAsync("prod-db");
var result = await client.RunCommandAsync("uptime");
Console.WriteLine($"exit {result.ExitStatus}: {result.StandardOutputText}");
No ssh_config? Pass the host, the credentials and a host key policy in SshClientOptions.
What it does
Connects like ssh
ssh_config aliases with Match and Include, ProxyJump chains,
ProxyCommand, HTTP and SOCKS proxies, your own transport, or any Stream. Jump hosts, algorithms
and timeouts as typed options too, and the connection's endpoints, byte counts and re-keying in code.
Verified by default
A host key verifier is required: known_hosts with OpenSSH's policies, host certificates,
revocation lists, pinning or your own rule. Nothing is accepted silently.
Commands and shells
Collect a command's output and exit status, stream it, drive an interactive shell with
SshExpect, or start a subsystem.
Tunnels and forwarding
Local, remote and dynamic (SOCKS, optionally with a SOCKS 5 password) forwarding, Unix sockets on either
end, remote forwarding to a handler in your code, and HttpClient through the connection.
Keys, agents, certificates
OpenSSH, PEM and PuTTY keys, export to PKCS#8 and PuTTY, ssh-agent and Pageant, an
in-process agent, FIDO keys through the agent, keys in a TPM or KMS, password prompts and changes, OpenSSH certificates (issued
as a CA too), revocation lists and Kerberos.
Modern cryptography
Post-quantum hybrid key exchange, ChaCha20-Poly1305 and AES-GCM, strict key exchange always on, a FIPS mode, and OpenSSH's delayed compression. Typed algorithm lists in code. No legacy algorithms.
AlgorithmsFits .NET applications
Dependency injection with keyed endpoints, a shared reconnecting connection, connection events,
HttpClient tunnels and health checks; SFTP as IFileSystem or IFileProvider; trimming and
Native AOT.
Observable
ILogger logging, ActivitySource traces and Meter metrics that follow
OpenTelemetry's conventions, with no secrets recorded.
Packages
| Package | What it adds |
|---|---|
SshSharp |
The client: connections, authentication, host keys, commands and shells, forwarding, SFTP and SCP, ssh_config and known_hosts, keys and signatures. |
SshSharp.Extensions.DependencyInjection |
Named endpoints from configuration, ISshClientFactory, a shared reconnecting ISshConnectionProvider, and a health check. |
SshSharp.IO.Abstractions |
SftpFileSystem: SFTP as a System.IO.Abstractions IFileSystem. |
SshSharp.FileProviders |
SftpFileProvider: a remote directory as an IFileProvider, for static files, Razor views and configuration. |
All four are released together with the same version, target .NET 8, .NET 10 and .NET 11, and have no native dependencies.
Where to go next
- New to SshSharp: Getting started, then the tutorial.
- A specific task: the how-to guides, each a short page with focused examples.
- A complete program: the scenarios: a deployment script, a fleet health check, a file sync job, a database through a jump host, a background worker.
- How it works: architecture and connection lifecycle, channels, threading and the security model.
- Coming from SSH.NET: the migration guide, the same tasks side by side.
- Something is wrong: troubleshooting and the FAQ.
Note
SshSharp 1.x follows semantic versioning: breaking changes wait for a major version. The managed cryptography has had an internal constant-time review but not yet an outside one; see the cryptography review and the security policy.