Table of Contents
SshSharp logo

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.

Get started How-to guides API reference

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.

ssh_config and known_hosts Jump hosts
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.

Verify host keys
Commands and shells

Collect a command's output and exit status, stream it, drive an interactive shell with SshExpect, or start a subsystem.

Run a command Shells
SFTP and SCP

Pipelined transfers, resume, segmented downloads and uploads, directory trees with filters and skipping of unchanged files, recursive listings, server-side hashes, remote file streams, and SCP for servers without SFTP.

SFTP SCP
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.

Port forwarding
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.

Keys and the agent Certificates
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.

Algorithms
Fits .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.

ASP.NET Core IFileSystem
Observable

ILogger logging, ActivitySource traces and Meter metrics that follow OpenTelemetry's conventions, with no secrets recorded.

Logging and diagnostics

See all features

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

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.