d0x2a.EmbeddedSsh
1.1.0
dotnet add package d0x2a.EmbeddedSsh --version 1.1.0
NuGet\Install-Package d0x2a.EmbeddedSsh -Version 1.1.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="d0x2a.EmbeddedSsh" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="d0x2a.EmbeddedSsh" Version="1.1.0" />
<PackageReference Include="d0x2a.EmbeddedSsh" />
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 d0x2a.EmbeddedSsh --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: d0x2a.EmbeddedSsh, 1.1.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 d0x2a.EmbeddedSsh@1.1.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=d0x2a.EmbeddedSsh&version=1.1.0
#tool nuget:?package=d0x2a.EmbeddedSsh&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EmbeddedSsh
A minimal, embeddable SSH-2 server library for .NET 10.0 following RFC 4251-4254.
Features
- Zero external dependencies - All cryptographic primitives implemented from scratch
- Pure managed code - No native libraries or P/Invoke
- RFC compliant - Implements SSH-2 protocol (RFC 4251-4254)
- Modern cryptography:
- ChaCha20-Poly1305 and AES-256-GCM ciphers
- Curve25519 key exchange
- Ed25519 host keys
- RSA and Ed25519 public key authentication
Supported Algorithms
| Type | Algorithms |
|---|---|
| Key Exchange | curve25519-sha256, curve25519-sha256@libssh.org |
| Host Key | ssh-ed25519 |
| Cipher | chacha20-poly1305@openssh.com, aes256-gcm@openssh.com |
| Authentication | publickey (ssh-ed25519, ssh-rsa, rsa-sha2-256, rsa-sha2-512), password |
Installation
dotnet add package d0x2a.EmbeddedSsh
Quick Start
using System.Net;
using d0x2a.EmbeddedSsh;
using d0x2a.EmbeddedSsh.Auth;
using d0x2a.EmbeddedSsh.HostKeys;
// Generate or load host key
var hostKey = Ed25519HostKey.Generate();
// Configure server
var options = new SshServerOptions
{
ServerVersion = "SSH-2.0-MyServer",
Authenticator = new PasswordAuthenticator(new Dictionary<string, string>
{
["user"] = "password"
})
};
options.HostKeys.Add(hostKey);
// Start server
await using var server = new SshServer(options, new IPEndPoint(IPAddress.Any, 2222));
server.ConnectionAccepted += connection =>
{
_ = Task.Run(async () =>
{
var channel = await connection.AcceptChannelAsync();
// Handle channel...
});
return Task.CompletedTask;
};
server.Start();
await Task.Delay(Timeout.Infinite);
Public Key Authentication
Use AuthorizedKeysAuthenticator for SSH key authentication:
// From authorized_keys file
var content = File.ReadAllText("~/.ssh/authorized_keys");
var keys = AuthorizedKeysAuthenticator.ParseAuthorizedKeysFile(content);
var options = new SshServerOptions
{
Authenticator = new AuthorizedKeysAuthenticator(
new Dictionary<string, IEnumerable<AuthorizedKey>>
{
["username"] = keys
})
};
Building
# Build
dotnet build
# Run tests
dotnet test
# Create NuGet package
dotnet pack -c Release
# Run example server
cd samples/EmbeddedSsh.Example
dotnet run
Architecture
The library follows the SSH RFC layered architecture:
+-----------------------------------------+
| SshServer | Server integration
+-----------------------------------------+
| Connection Layer | Channels, requests
+-----------------------------------------+
| Auth Layer | Authentication
+-----------------------------------------+
| Transport Layer | Encryption, framing
+-----------------------------------------+
| Protocol Layer | Message serialization
+-----------------------------------------+
| Crypto Layer | Primitives
+-----------------------------------------+
Requirements
- .NET 10.0
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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.
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.