@@ -6,36 +6,65 @@ SSH.NET is a Secure Shell (SSH-2) library for .NET, optimized for parallelism.
66[ ![ NuGet download count] ( https://img.shields.io/nuget/dt/SSH.NET.svg )] ( https://www.nuget.org/packages/SSH.NET )
77[ ![ Build status] ( https://ci.appveyor.com/api/projects/status/ih77qu6tap3o92gu/branch/develop?svg=true )] ( https://ci.appveyor.com/api/projects/status/ih77qu6tap3o92gu/branch/develop )
88
9- ## Introduction
9+ ## Key Features
1010
11- This project was inspired by ** Sharp.SSH** library which was ported from java and it seems like was not supported
12- for quite some time. This library is a complete rewrite, without any third party dependencies, using parallelism
13- to achieve the best performance possible.
11+ * Execution of SSH command using both synchronous and asynchronous methods
12+ * SFTP functionality for both synchronous and asynchronous operations
13+ * SCP functionality
14+ * Remote, dynamic and local port forwarding
15+ * Interactive shell/terminal implementation
16+ * Authentication via publickey, password and keyboard-interactive methods, including multi-factor
17+ * Connection via SOCKS4, SOCKS5 or HTTP proxy
1418
15- ## Documentation
19+ ## How to Use
1620
17- Documentation is hosted at https://sshnet.github.io/SSH.NET/ . Currently (4/18/2020), the documentation is very sparse.
18- Fortunately, there are a large number of [ tests] ( https://github.com/sshnet/SSH.NET/tree/develop/test/ ) that demonstrate usage with working code.
19- If the test for the functionality you would like to see documented is not complete, then you are cordially
20- invited to read the source, Luke, and highly encouraged to generate a pull request for the implementation of
21- the missing test once you figure things out. 🤓
21+ ### Run a command
2222
23- ## Features
23+ ``` cs
24+ using (var client = new SshClient (" sftp.foo.com" , " guest" , new PrivateKeyFile (" path/to/my/key" )))
25+ {
26+ client .Connect ();
27+ using SshCommand cmd = client .RunCommand (" echo 'Hello World!'" );
28+ Console .WriteLine (cmd .Result ); // "Hello World!\n"
29+ }
30+ ```
2431
25- * Execution of SSH command using both synchronous and asynchronous methods
26- * Return command execution exit status and other information
27- * Provide SFTP functionality for both synchronous and asynchronous operations
28- * Provides SCP functionality
29- * Provide status report for upload and download sftp operations to allow accurate progress bar implementation
30- * Remote, dynamic and local port forwarding
31- * Shell/Terminal implementation
32- * Specify key file pass phrase
33- * Use multiple key files to authenticate
34- * Supports publickey, password and keyboard-interactive authentication methods
35- * Supports two-factor or higher authentication
36- * Supports SOCKS4, SOCKS5 and HTTP Proxy
32+ ### Upload and list files using SFTP
33+
34+ ``` cs
35+ using (var client = new SftpClient (" sftp.foo.com" , " guest" , " pwd" ))
36+ {
37+ client .Connect ();
38+
39+ using (FileStream fs = File .OpenRead (@" C:\tmp\test-file.txt" ))
40+ {
41+ client .UploadFile (fs , " /home/guest/test-file.txt" );
42+ }
43+
44+ foreach (ISftpFile file in client .ListDirectory (" /home/guest/" ))
45+ {
46+ Console .WriteLine ($" {file .FullName } {file .LastWriteTime }" );
47+ }
48+ }
49+ ```
50+
51+ ## Main Types
52+
53+ The main types provided by this library are:
54+
55+ * Renci.SshNet.SshClient
56+ * Renci.SshNet.SftpClient
57+ * Renci.SshNet.ScpClient
58+ * Renci.SshNet.PrivateKeyFile
59+ * Renci.SshNet.SshCommand
60+ * Renci.SshNet.ShellStream
61+
62+ ## Additional Documentation
3763
38- ## Encryption Method
64+ * [ Further examples] ( https://sshnet.github.io/SSH.NET/examples.html )
65+ * [ API browser] ( https://sshnet.github.io/SSH.NET/api/Renci.SshNet.html )
66+
67+ ## Encryption Methods
3968
4069** SSH.NET** supports the following encryption methods:
4170* aes128-ctr
@@ -57,7 +86,7 @@ the missing test once you figure things out. 🤓
5786* arcfour256
5887* cast128-cbc
5988
60- ## Key Exchange Method
89+ ## Key Exchange Methods
6190
6291** SSH.NET** supports the following key exchange methods:
6392* curve25519-sha256
@@ -131,41 +160,6 @@ Private keys can be encrypted using one of the following cipher methods:
131160* .NET Standard 2.0 and 2.1
132161* .NET 6 (and higher)
133162
134- ## Usage
135-
136- ### Multi-factor authentication
137-
138- Establish a SFTP connection using both password and public-key authentication:
139-
140- ``` cs
141- var connectionInfo = new ConnectionInfo (" sftp.foo.com" ,
142- " guest" ,
143- new PasswordAuthenticationMethod (" guest" , " pwd" ),
144- new PrivateKeyAuthenticationMethod (" rsa.key" ));
145- using (var client = new SftpClient (connectionInfo ))
146- {
147- client .Connect ();
148- }
149-
150- ```
151-
152- ### Verify host identify
153-
154- 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:
155-
156- ``` cs
157- string expectedFingerPrint = " LKOy5LvmtEe17S4lyxVXqvs7uPMy+yF79MQpHeCs/Qo" ;
158-
159- using (var client = new SshClient (" sftp.foo.com" , " guest" , " pwd" ))
160- {
161- client .HostKeyReceived += (sender , e ) =>
162- {
163- e .CanTrust = expectedFingerPrint .Equals (e .FingerPrintSHA256 );
164- };
165- client .Connect ();
166- }
167- ```
168-
169163## Building the library
170164
171165The library has no special requirements to build, other than an up-to-date .NET SDK. See also [ CONTRIBUTING.md] ( https://github.com/sshnet/SSH.NET/blob/develop/CONTRIBUTING.md ) .
0 commit comments