sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
MIT License
3.87k stars 915 forks source link
hacktoberfest network scp sftp ssh

Logo SSH.NET

SSH.NET is a Secure Shell (SSH-2) library for .NET, optimized for parallelism.

Version NuGet download count Build status

Introduction

This project was inspired by Sharp.SSH library which was ported from java and it seems like was not supported for quite some time. This library is a complete rewrite, without any third party dependencies, using parallelism to achieve the best performance possible.

Documentation

Documentation is hosted at https://sshnet.github.io/SSH.NET/. Currently (4/18/2020), the documentation is very sparse. Fortunately, there are a large number of tests that demonstrate usage with working code. If the test for the functionality you would like to see documented is not complete, then you are cordially invited to read the source, Luke, and highly encouraged to generate a pull request for the implementation of the missing test once you figure things out. 🤓

Features

Encryption Method

SSH.NET supports the following encryption methods:

Key Exchange Method

SSH.NET supports the following key exchange methods:

Public Key Authentication

SSH.NET supports the following private key formats:

Private keys can be encrypted using one of the following cipher methods:

Host Key Algorithms

SSH.NET supports the following host key algorithms:

Message Authentication Code

SSH.NET supports the following MAC algorithms:

Compression

SSH.NET supports the following compression algorithms:

Framework Support

SSH.NET supports the following target frameworks:

Usage

Multi-factor authentication

Establish a SFTP connection using both password and public-key authentication:

var connectionInfo = new ConnectionInfo("sftp.foo.com",
                                        "guest",
                                        new PasswordAuthenticationMethod("guest", "pwd"),
                                        new PrivateKeyAuthenticationMethod("rsa.key"));
using (var client = new SftpClient(connectionInfo))
{
    client.Connect();
}

Verify host identify

Establish a SSH connection using user name and password, and reject the connection if the fingerprint of the server does not match the expected fingerprint:

string expectedFingerPrint = "LKOy5LvmtEe17S4lyxVXqvs7uPMy+yF79MQpHeCs/Qo";

using (var client = new SshClient("sftp.foo.com", "guest", "pwd"))
{
    client.HostKeyReceived += (sender, e) =>
        {
            e.CanTrust = expectedFingerPrint.Equals(e.FingerPrintSHA256);
        };
    client.Connect();
}

Building the library

The library has no special requirements to build, other than an up-to-date .NET SDK. See also CONTRIBUTING.md.

Supporting SSH.NET

Do you or your company rely on SSH.NET in your projects? If you want to encourage us to keep on going and show us that you appreciate our work, please consider becoming a sponsor through GitHub Sponsors.