NullOpsDevs.LibSsh
1.1.4
dotnet add package NullOpsDevs.LibSsh --version 1.1.4
NuGet\Install-Package NullOpsDevs.LibSsh -Version 1.1.4
<PackageReference Include="NullOpsDevs.LibSsh" Version="1.1.4" />
<PackageVersion Include="NullOpsDevs.LibSsh" Version="1.1.4" />
<PackageReference Include="NullOpsDevs.LibSsh" />
paket add NullOpsDevs.LibSsh --version 1.1.4
#r "nuget: NullOpsDevs.LibSsh, 1.1.4"
#:package NullOpsDevs.LibSsh@1.1.4
#addin nuget:?package=NullOpsDevs.LibSsh&version=1.1.4
#tool nuget:?package=NullOpsDevs.LibSsh&version=1.1.4
NullOpsDevs.LibSsh
A modern, cross-platform .NET library providing managed bindings for libssh2, enabling SSH operations including remote command execution, SCP file transfers, and advanced terminal (PTY) features.
Features
| Category | Feature | Method(s) | Supported |
|---|---|---|---|
| Authentication | |||
| Password authentication | Authenticate(PasswordCredential) |
✅ | |
| Public key authentication | Authenticate(PublicKeyCredential) |
✅ | |
| SSH agent authentication | Authenticate(SshAgentCredential) |
✅ | |
| Host-based authentication | Authenticate(HostBasedCredential) |
✅ | |
| Keyboard-interactive authentication | - | ❌ | |
| Session Management | |||
| Connection | Connect, ConnectAsync |
✅ | |
| Host key retrieval | GetHostKey |
✅ | |
| Host key verification | GetHostKeyHash |
✅ | |
| Session timeout configuration | SetSessionTimeout, DisableSessionTimeout |
✅ | |
| Keepalive configuration | ConfigureKeepAlive, SendKeepAlive |
✅ | |
| Method preference configuration | SetMethodPreferences |
✅ | |
| Secure default algorithms | SetSecureMethodPreferences |
✅ | |
| Negotiated method inspection | GetNegotiatedMethod |
✅ | |
| File Transfer (SCP) | |||
| File upload | WriteFile, WriteFileAsync |
✅ | |
| File download | ReadFile, ReadFileAsync |
✅ | |
| Command Execution | |||
| One-shot command execution | ExecuteCommand, ExecuteCommandAsync |
✅ | |
| Exit code retrieval | SshCommandResult.ExitCode |
✅ | |
| Exit signal retrieval | SshCommandResult.ExitSignal |
✅ | |
| stdout/stderr separation | SshCommandResult.Stdout, SshCommandResult.Stderr |
✅ | |
| Terminal (PTY) | |||
| PTY allocation | CommandExecutionOptions.RequestPty |
✅ | |
| Terminal type selection | CommandExecutionOptions.TerminalType |
✅ | |
| Terminal modes | CommandExecutionOptions.TerminalModes |
✅ | |
| Window size configuration | CommandExecutionOptions.TerminalWidth/Height |
✅ | |
| Interactive shell mode | - | ❌ | |
| Error Handling | |||
| Typed exceptions | SshException |
✅ | |
| Detailed error messages | SshException.Message |
✅ | |
| 60+ error code mappings | SshError enum |
✅ | |
| Advanced Features | |||
| Host key type detection | SshHostKey.Type |
✅ | |
| Microsoft.Extensions.Logging integration | Constructor ILogger parameter |
✅ | |
| Cross-platform native binaries | Bundled in NuGet package | ✅ | |
| Global library cleanup | LibSsh2.Exit() |
✅ | |
| Thread Safety | |||
SshSession is NOT thread-safe. |
- | ❌ | |
Multiple SshSessions are supported. |
- | ✅ |
Installation
Install via NuGet Package Manager:
dotnet add package NullOpsDevs.LibSsh
Or via Package Manager Console:
Install-Package NullOpsDevs.LibSsh
Supported Platforms
- .NET 9.0+
- Windows (x64)
- Linux (x64, ARM64)
- macOS (x64, ARM64/Apple Silicon)
Quick Start
Quickstart guide is available here.
Building from Source
Prerequisites
- .NET 9.0 SDK or later
- Git
Build Steps
# Clone the repository
git clone https://github.com/NullOpsDevs/LibSshNet.git
cd LibSshNet
# Restore dependencies and build
dotnet restore
dotnet build
# Run tests
cd NullOpsDevs.LibSsh.Test
docker compose up -d
dotnet run
Architecture
The library consists of three layers:
- Managed Layer: Clean, idiomatic C# API with async/await support (not true async)
- Interop Layer: P/Invoke bindings to libssh2 native library
- Native Layer: Pre-compiled libssh2 binaries for all supported platforms
All native dependencies are bundled in the NuGet package for zero-configuration deployment.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
This library uses libssh2, a client-side C library implementing the SSH2 protocol.
libssh2 is licensed under BSD License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 is compatible. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0-preview.1.25080.5)
-
net6.0
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
-
net7.0
- Microsoft.Extensions.Logging.Abstractions (>= 7.0.0)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.4 | 135 | 11/4/2025 |
| 1.1.3 | 165 | 11/3/2025 |
| 1.1.2 | 167 | 11/3/2025 |
| 1.1.1 | 169 | 11/2/2025 |
| 1.1.0 | 172 | 11/2/2025 |
| 1.0.0 | 105 | 11/1/2025 |
| 1.0.0-deploy-test | 107 | 11/1/2025 |
| 1.0.0-dep-test-and-multiarch | 103 | 11/1/2025 |