mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 17:25:51 +00:00
2bbfee4a37
* Assets/logos (#782) * Added logo assets * Added PNG 1260x640 with white border Co-authored-by: 103filgualan <f.gualandi@crif.com> * OPENSSH KeyReader for more keys (#614) * OPENSSH KeyReader for more keys Add support to parse OpenSSH Keys with ECDSA 256/384/521 and RSA. https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key Change-Id: Iaa9cce0f2522e5fee377a82cb252f81f0b7cc563 * Fix ED25519Key KeyLength * Fix ED25519 PubKey-auth LeadingZeros of BigInteger-Conversion have to be removed before sending the Key. * Add interface to SftpFile #120 (#812) * Create ISftpFile interface. SftpFile sealed. Return ISftpFile from SftpClient instead of SftpFile. Make ISftpClient interface disposable. Co-authored-by: Wojciech Swieboda <wswieboda@chathamfinancial.com> * Start MessageListener with ThreadAbstraction.ExecuteThreadLongRunning (#902) * Fix Thread pool exhaustion due to MessageListener running on ThreadPool * Mark long running thread as background * Add async support to SftpClient and SftpFileStream (#819) * Add FEATURE_TAP and net472 target * Add TAP async support to SftpClient and SftpFileStream * Add async support to DnsAbstraction and SocketAbstraction * Add async support to *Connector and refactor the hierarchy * Add ConnectAsync to BaseClient * Add CODEOWNERS file. * Fix virus false-positive by Defender on Renci.SSHNet.Tests.dll (#867) Co-authored-by: Pedro Fonseca <pfonseca@qti.qualcomm.com> * Add unit tests for task-based asynchronous API (#906) * Fix runtime and culture dependant tests. * Set C# 7.3 in Tests.csproj to limit intellisense's suggestions under different targets * Add SftpClientTest.*Async * Add SftpFileStreamTest_OpenAsync_* * Add SftpFileStreamTest_WriteAsync_* * Add SftpFileStreamTest_ReadAsync_* * Align AppVeyor script with Test project target frameworks * correct 'Documenation' to 'Documentation' (#838) in the documentation's window title * Agent auth and Keygen (#794) * Allow to set PrivateKeyFile Key directly So you can add your own Key-Classes to SSH.NET * Add ED25519 ctor for just pub key part. * Make ECDSA Key Bits accessible You cant export imported CngKeys. To be able to export them to agent or Key-Files make the private bits also accessible. * Better NETFRAMEWORK vs NETSTANDARD handling * Add Comment Property to Key * Add IPrivateKeySource So Extension can add own PrivateKeyFiles, e.g. PuttyKeyFile. * Use cryptographically secure random number generator. Fixes CVE-2022-29245. * Remove unused import. * Add IBaseClient for BaseClient and ISftpClient to inherit from (#975) Add IBaseClient for BaseClient and ISftpClient to inherit from * fix typo (#999) * Fix Seek Operations in SftpFileStream (#910) * Fix offset operations in SftpFileStream.Seek * Fix seek exception message and add default case for invalid seek origin * Use named params when throwing ArgumentException * Add tests for seeking from end of file * Add back copyright to license. (#1060) Fixes #1059. * Removing old target frameworks (#1109) Remove support for legacy / deprecated target frameworks while adding support for .NET 6.0 (and higher). The supported target frameworks are now: * .NETFramework 4.6.2 (and higher) * .NET Standard 2.0 * .NET 6.0 (and higher) * Remove old features [Part 1] (#1117) Remove obsolete feature switches (now that we've remove support for legacy target frameworks) and remove corresponding conditional code. * Remove FEATURE_DIRECTORYINFO_ENUMERATEFILES (#1119) * Remove FEATURE_DIRECTORYINFO_ENUMERATEFILES * Add exception documentation * Fix some (lots of) issues reported by analyzers. (#1125) Fix some (lots of) issues reported by analyzers. * Round 2 of analyzer fixes and general cleanup. (#1132) * Analyzer fixes round 3. (#1135) * Replace Array<T>.Empty with Array.Empty<T>() (#1137) * Replace IsNullOrWhiteSpace extension (#1142) * Use License Expression for NuGet Package licenseUrl is deprecated, see https://github.com/NuGet/Announcements/issues/32 * Integration tests * Remove todos * Update CODEOWNERS * Use correct SSH.NET * ListDirectoryAsync return IAsyncEnumerable (#1126) * ListDirectoryAsync return IAsyncEnumerable * Fix documentation * Update README.md * Fix * Add Sftp ListDirectoryAsync test * Revert * Integration tests for ListDirectoryAsync with IAsyncEnumerable * Fix the assembly resolution build warning (#1165) * Delete performance/longrunning tests (#1143) Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com> * Move Integration tests (#1173) * Renci.SshNet.IntegrationTests * Renci.SshNet.TestTools.OpenSSH * Move integration tests to main repo * Move old tests to new integration tests * Move old integration tests to new integration tests * Move more tests * Move authentication tests * Move SshClientTests * Fix some tests * Remove duplicated test * Poc of ProcessDisruptor * Rename * Some fixes * Remove performance tests * Small improvements * Add a benchmarks project (#1151) * Add a benchmarks project * Small improvements --------- Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com> * Use ExceptionDispatchInfo to retain call stack in Session.WaitOnHandle() (#936) * Use ExceptionDispatchInfo to retain call stack in Session.WaitOnHandle() * merge * Update src/Renci.SshNet/Session.cs Co-authored-by: Rob Hague <rob.hague00@gmail.com> --------- Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com> Co-authored-by: Rob Hague <rob.hague00@gmail.com> * Support SHA256 fingerprints for host key validation (#1098) * Add tests for HostKeyEventArgs * Add SHA256 fingerprint support * Add support for RSA SHA-2 public key algorithms (#1177) * Abstract out the hash algorithm from RsaDigitalSignature * Add integration tests * Add DigitalSignature property to KeyHostAlgorithm * Add IHostAlgorithmsProvider interface * Verify the host signature * Fix HostKeyEventArgsTest after merge * Remove PubkeyAcceptedAlgorithms ssh-rsa * Add test coverage for RSA keys in PrivateKeyFile * Obsolete IPrivateKeySource --------- Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com> * Improvements after #1177 (#1180) * Use ExceptionDispatchInfo in more places (#1182) Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com> * Try to "fix" the flaky test (#1185) * Enable DSA tests (#1181) Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com> * FingerPrints (#1186) * Use OS-agnostic socket error codes to allow tests run on different OSes (#1179) SocketErrorCode is OS agnostic, ErrorCode is OS specific. On Windows ErrorCode = (int) SocketErrorCode, but on Mac and Unix it is not. For example ExitCode for HostNotFound (11001) on Windows is 11001, on Mac & Unix is -131073. So testing for ExitCode == 11001 fails on Mac & Unix. Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com> * Fix for channel session semaphore from thread blocking (#1071) * Merging fix from @clivetong into our own SSH.NET fork - The following article describes some of the issues with the double check lock that we have seen issues with: https://www.sudhanshutheone.com/posts/double-check-lock-csharp * Merging fix from @clivetong into our own SSH.NET fork - The following article describes some of the issues with the double check lock that we have seen issues with: https://www.sudhanshutheone.com/posts/double-check-lock-csharp * Update Channel to fix AppVeyor failure (field should be readonly) * Update ISftpClient for #120 (#1193) * Implement set last write and access time (#1194) * Add/migrate hmac+cipher integration tests (#1189) * Add/migrate hmac+cipher integration tests * fix integration tests --------- Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com> * Update tests for SetLastAccessTime(Utc) to also verify the time component and the Kind of the DateTime value returned by GetLastAccessTime(Utc). (#1198) --------- Co-authored-by: Filippo Gualandi <filippo.gualandi@gmail.com> Co-authored-by: 103filgualan <f.gualandi@crif.com> Co-authored-by: Stefan Rinkes <darinkes@users.noreply.github.com> Co-authored-by: wxtsxt <wojciech.swieboda@gmail.com> Co-authored-by: Wojciech Swieboda <wswieboda@chathamfinancial.com> Co-authored-by: Igor Milavec <igor.milavec@gmail.com> Co-authored-by: drieseng <gert.driesen@telenet.be> Co-authored-by: Pedro Fonseca <pbfonseca@gmail.com> Co-authored-by: Pedro Fonseca <pfonseca@qti.qualcomm.com> Co-authored-by: Maximiliano Jabase <maxijabase@gmail.com> Co-authored-by: Owen Krueger <37021716+Owen-Krueger@users.noreply.github.com> Co-authored-by: Masuri <psh0258@gmail.com> Co-authored-by: LemonPi314 <49930425+LemonPi314@users.noreply.github.com> Co-authored-by: Gert Driesen <gertdriesen@msn.com> Co-authored-by: Rob Hague <rob.hague00@gmail.com> Co-authored-by: Rob Hague <rh@johnstreetcapital.com> Co-authored-by: Marius Thesing <marius.thesing@gmail.com> Co-authored-by: Dāvis Mošenkovs <davikovs@gmail.com> Co-authored-by: Dmitry Tsarevich <dimhotepus@users.noreply.github.com> Co-authored-by: Patrick Yates <114094360+patrick-yates-redgate@users.noreply.github.com>
163 lines
5.4 KiB
Markdown
163 lines
5.4 KiB
Markdown
 SSH.NET
|
|
=======
|
|
SSH.NET is a Secure Shell (SSH-2) library for .NET, optimized for parallelism.
|
|
|
|
[](https://www.nuget.org/packages/SSH.NET)
|
|
[](https://www.nuget.org/packages/SSH.NET)
|
|
[](https://ci.appveyor.com/api/projects/status/ih77qu6tap3o92gu/branch/develop)
|
|
|
|
## 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
|
|
There is MSDN-style class documentation in a .chm file for each release, which you can find in the Assets section
|
|
of the [latest release](https://github.com/sshnet/SSH.NET/releases/latest) page. Please note that you will need
|
|
to [right-click and "unblock"](https://support.microsoft.com/en-us/help/2021383/some-chm-files-may-not-render-properly-on-windows-vista-and-windows-7)
|
|
the CHM file after you download it.
|
|
|
|
Currently (4/18/2020), the documentation is very sparse. Fortunately, there are a large number of tests in
|
|
[Renci.SshNet.Tests](https://github.com/sshnet/SSH.NET/tree/develop/src/Renci.SshNet.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
|
|
* Execution of SSH command using both synchronous and asynchronous methods
|
|
* Return command execution exit status and other information
|
|
* Provide SFTP functionality for both synchronous and asynchronous operations
|
|
* Provides SCP functionality
|
|
* Provide status report for upload and download sftp operations to allow accurate progress bar implementation
|
|
* Remote, dynamic and local port forwarding
|
|
* Shell/Terminal implementation
|
|
* Specify key file pass phrase
|
|
* Use multiple key files to authenticate
|
|
* Supports publickey, password and keyboard-interactive authentication methods
|
|
* Supports two-factor or higher authentication
|
|
* Supports SOCKS4, SOCKS5 and HTTP Proxy
|
|
|
|
## Encryption Method
|
|
|
|
**SSH.NET** supports the following encryption methods:
|
|
* aes256-ctr
|
|
* 3des-cbc
|
|
* aes128-cbc
|
|
* aes192-cbc
|
|
* aes256-cbc
|
|
* blowfish-cbc
|
|
* twofish-cbc
|
|
* twofish192-cbc
|
|
* twofish128-cbc
|
|
* twofish256-cbc
|
|
* arcfour
|
|
* arcfour128
|
|
* arcfour256
|
|
* cast128-cbc
|
|
* aes128-ctr
|
|
* aes192-ctr
|
|
|
|
## Key Exchange Method
|
|
|
|
**SSH.NET** supports the following key exchange methods:
|
|
* curve25519-sha256
|
|
* curve25519-sha256<span></span>@libssh.org
|
|
* ecdh-sha2-nistp256
|
|
* ecdh-sha2-nistp384
|
|
* ecdh-sha2-nistp521
|
|
* diffie-hellman-group-exchange-sha256
|
|
* diffie-hellman-group-exchange-sha1
|
|
* diffie-hellman-group16-sha512
|
|
* diffie-hellman-group14-sha256
|
|
* diffie-hellman-group14-sha1
|
|
* diffie-hellman-group1-sha1
|
|
|
|
## Public Key Authentication
|
|
|
|
**SSH.NET** supports the following private key formats:
|
|
* RSA in OpenSSL PEM and ssh.com format
|
|
* DSA in OpenSSL PEM and ssh.com format
|
|
* ECDSA 256/384/521 in OpenSSL PEM format
|
|
* ECDSA 256/384/521, ED25519 and RSA in OpenSSH key format
|
|
|
|
Private keys can be encrypted using one of the following cipher methods:
|
|
* DES-EDE3-CBC
|
|
* DES-EDE3-CFB
|
|
* DES-CBC
|
|
* AES-128-CBC
|
|
* AES-192-CBC
|
|
* AES-256-CBC
|
|
|
|
## Host Key Algorithms
|
|
|
|
**SSH.NET** supports the following host key algorithms:
|
|
* ssh-ed25519
|
|
* ecdsa-sha2-nistp256
|
|
* ecdsa-sha2-nistp384
|
|
* ecdsa-sha2-nistp521
|
|
* rsa-sha2-512
|
|
* rsa-sha2-256
|
|
* ssh-rsa
|
|
* ssh-dss
|
|
|
|
## Message Authentication Code
|
|
|
|
**SSH.NET** supports the following MAC algorithms:
|
|
* hmac-md5
|
|
* hmac-md5-96
|
|
* hmac-sha1
|
|
* hmac-sha1-96
|
|
* hmac-sha2-256
|
|
* hmac-sha2-256-96
|
|
* hmac-sha2-512
|
|
* hmac-sha2-512-96
|
|
* hmac-ripemd160
|
|
* hmac-ripemd160<span></span>@openssh.com
|
|
|
|
## Framework Support
|
|
**SSH.NET** supports the following target frameworks:
|
|
* .NETFramework 4.6.2 (and higher)
|
|
* .NET Standard 2.0 and 2.1
|
|
* .NET 6 (and higher)
|
|
|
|
## Usage
|
|
|
|
### Multi-factor authentication
|
|
|
|
Establish a SFTP connection using both password and public-key authentication:
|
|
|
|
```cs
|
|
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:
|
|
|
|
```cs
|
|
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();
|
|
}
|
|
```
|
|
|
|
## 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](https://github.com/sponsors/sshnet) through GitHub Sponsors.
|