SSH.NET is a Secure Shell (SSH-2) library for .NET, optimized for parallelism.
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 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. 🤓
SSH.NET supports the following encryption methods:
SSH.NET supports the following key exchange methods:
SSH.NET supports the following private key formats:
Private keys can be encrypted using one of the following cipher methods:
SSH.NET supports the following host key algorithms:
SSH.NET supports the following MAC algorithms:
SSH.NET supports the following compression algorithms:
SSH.NET supports the following target frameworks:
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();
}
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();
}
The library has no special requirements to build, other than an up-to-date .NET SDK. See also CONTRIBUTING.md.
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.