SshSharp 0.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SshSharp --version 0.3.0
                    
NuGet\Install-Package SshSharp -Version 0.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SshSharp" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SshSharp" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="SshSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SshSharp --version 0.3.0
                    
#r "nuget: SshSharp, 0.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SshSharp@0.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SshSharp&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=SshSharp&version=0.3.0
                    
Install as a Cake Tool

SshSharp

CI NuGet .NET License: MIT

A managed, async-first SSH client library for .NET, with OpenSSH ssh_config and known_hosts support. Connect to a host by its ssh_config alias and get the same host name, user, keys, agent, jump hosts and host key policy that ssh would use.

await using var client = await SshClient.ConnectAsync("prod-db");   // an alias from ~/.ssh/config
var result = await client.RunCommandAsync("uptime");
Console.WriteLine(result.StandardOutputText);

Status: pre-1.0 (0.x releases). The API may still change before 1.0, and the managed cryptography has had an internal constant-time review but not yet an outside one. See SECURITY.md.

Features

  • Pure managed C#, no native dependencies; .NET 8 and .NET 10, tested on Windows and Linux (x64 and Arm64) and macOS (Arm64); trimming- and Native AOT-compatible, with an AOT-compiled smoke test against a real server in CI.
  • Async all the way: CancellationToken on every network operation, IAsyncDisposable, System.IO.Pipelines I/O with zero-copy packet handling.
  • OpenSSH configuration: ssh_config (Host, Match, Include, tokens) and known_hosts (hashed hosts, @cert-authority, @revoked), resolved like ssh -G.
  • Authentication: password, public keys (OpenSSH, PKCS#8, PKCS#1/SEC1 and PuTTY .ppk formats, encrypted too), OpenSSH user certificates, ssh-agent (Unix sockets and the Windows OpenSSH agent) and agent forwarding, keyboard-interactive (one-time codes, PAM), and multi-factor chains.
  • Host verification: StrictHostKeyChecking policies, host certificates, UpdateHostKeys, key pinning, or your own verifier. There is no "accept anything" default.
  • Connections: ProxyJump chains, ProxyCommand, connect over any Stream, keep-alive and dead-connection detection; TCP and Unix-socket tunnels; local, remote and dynamic (SOCKS) port forwarding (ssh -L, -R, -D), also started from ssh_config.
  • Sessions: run commands, stream stdin/stdout/stderr, interactive shells with a pseudo-terminal, environment variables, signals and window resizing.
  • Modern algorithms: post-quantum mlkem768x25519-sha256 (on .NET 10 where the platform has ML-KEM), curve25519-sha256, ECDH and DH group 14/16 key exchange; ChaCha20-Poly1305, AES-GCM and AES-CTR with HMAC-SHA2 ETM; Ed25519, ECDSA and RSA (SHA-2) keys; strict key exchange (Terrapin) always on; a FIPS mode.
  • File transfer: SCP uploads and downloads of files, streams and directories, with progress, kept times, and checks that stop a hostile server from writing outside the target.
  • Observability: ILogger logging, ActivitySource tracing and Meter metrics, with no secrets recorded.

Coming next: SFTP, as a separate package.

Why not SSH.NET?

SSH.NET is the established .NET SSH library, and for some projects it is the better choice (see below). SshSharp is for applications that should behave like OpenSSH's ssh: connect by ssh_config alias, trust what known_hosts says, sign with the user's agent, hop through jump hosts, and do all of it asynchronously.

SshSharp SSH.NET 2026.0
Target frameworks .NET 8, .NET 10 .NET Framework 4.6.2+, .NET Standard 2.0, .NET 8+
API Async-only network API; CancellationToken on every network operation Mostly synchronous; async connect, commands and SFTP
ssh_config (Host, Match, Include; connect by alias) ✅ ❌
known_hosts verification (hashed hosts, @cert-authority, @revoked, StrictHostKeyChecking) ✅ ❌ (verify in a HostKeyReceived handler)
UpdateHostKeys (key rotation) ✅ ❌
ProxyJump chains, ProxyCommand ✅ ❌ (SOCKS4/5 and HTTP proxies)
SSH agent (ssh-agent, Windows OpenSSH agent) ✅ ❌
Agent forwarding ✅ ❌
Password, public key, keyboard-interactive, multi-factor ✅ ✅
OpenSSH certificates User and host User (authentication)
Private key formats OpenSSH, PKCS#1/#8, SEC1, PuTTY .ppk OpenSSH, PKCS#1/#8, PuTTY .ppk, ssh.com
Post-quantum key exchange mlkem768x25519-sha256 (.NET 10 with platform ML-KEM) mlkem768x25519-sha256, sntrup761x25519-sha512
Strict key exchange (Terrapin fix) ✅ ✅
Legacy algorithms (CBC, 3DES, SHA-1, ssh-rsa, DH group 1, zlib) — (by design) ✅
Commands, shells with a terminal ✅ ✅
Local, remote and dynamic port forwarding ✅ (also Unix-socket tunnels, and from ssh_config) ✅
SCP ✅ ✅
SFTP Planned (SshSharp.Sftp) ✅
Native AOT ✅ (an AOT-compiled binary connects to a real server in CI) ✅ (AOT-compatible; an AOT publish is checked in CI)
Diagnostics ILogger, ActivitySource tracing, Meter metrics ILogger
Fuzzing ✅ (coverage-guided, nightly; every parser in each test run) ❌
Mutation testing ✅ (Stryker.NET, weekly) ❌
Maturity New, pre-1.0; managed crypto awaiting an outside review More than a decade of production use

Use SSH.NET instead when you need .NET Framework or .NET Standard, SFTP today, servers that only speak legacy algorithms, a connection through an HTTP or SOCKS proxy, or a long track record. Moving from SSH.NET? See the migration guide.

Install

dotnet add package SshSharp

Examples

Connect with a key and verify the host against ~/.ssh/known_hosts:

using SshSharp;
using SshSharp.Config;

using var key = await SshPrivateKey.LoadFileAsync("/home/me/.ssh/id_ed25519");
await using var client = await SshClient.ConnectAsync("example.com", 22, new SshClientOptions
{
    UserName = "deploy",
    PrivateKeys = [key],
    HostKeyVerifier = KnownHostsVerifier.ForCurrentUser(StrictHostKeyChecking.Yes),
});

var result = await client.RunCommandAsync("df -h /");
Console.WriteLine($"exit {result.ExitStatus}: {result.StandardOutputText}");

Stream a long-running command:

await using var session = await client.StartCommandAsync("tail -f /var/log/syslog");
using var reader = new StreamReader(session.StandardOutput);
while (await reader.ReadLineAsync() is { } line)
{
    Console.WriteLine(line);
}

Use the keys in ssh-agent:

var agent = SshAgent.FromEnvironment();
var keys = agent is null ? [] : await agent.GetKeysAsync();

Documentation

Building

  • .NET SDK 10.0.401 or later (see global.json).
  • Build: dotnet build -c Release
  • Test (TUnit): dotnet test --project tests/SshSharp.Tests -c Release. Tests against real servers run when SSHSHARP_TEST_SSHD and related variables are set; CI sets them up on Linux, and . ./scripts/test-server.ps1 starts the same server in Docker locally (-Server dropbear for Dropbear, -Stop to remove it).
  • Coverage report: ./scripts/coverage.ps1 (target 95%+, not enforced in CI).
  • Mutation testing (Stryker.NET, weekly in CI): dotnet tool restore, then in tests/SshSharp.Tests: dotnet stryker --test-runner mtp --project SshSharp.csproj --target-framework net10.0 -m "**/Crypto/X25519.cs".
  • Releases: pushing a v* tag on main publishes to nuget.org (.github/workflows/publish.yml).

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on SshSharp:

Package Downloads
SshSharp.FileProviders

An IFileProvider over SFTP (SshSharp): serve files from an SSH server to ASP.NET Core static files, Razor, configuration and anything else that reads through Microsoft.Extensions.FileProviders.

SshSharp.IO.Abstractions

An IFileSystem (System.IO.Abstractions) over SFTP (SshSharp): code written against IFileSystem reads and writes a directory on an SSH server, with nothing mounted.

SshSharp.Extensions.DependencyInjection

Dependency injection for SshSharp: named SSH endpoints from configuration, a factory for new connections, a shared connection that reconnects, and a health check.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 2,111 10/17/2026
0.6.0 1,480 10/16/2026
0.5.0 3,305 10/14/2026
0.4.0 45 10/14/2026
0.3.0 732 10/14/2026