Skip to content

Commit 8e8829e

Browse files
authored
Docs updates (#1432)
* Use /// <value> instead of /// <returns> for properties * misc doc updates in SshCommand * Update README
1 parent 56318a4 commit 8e8829e

File tree

10 files changed

+119
-131
lines changed

10 files changed

+119
-131
lines changed

README.md

+54-60
Original file line numberDiff line numberDiff line change
@@ -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

171165
The 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).

docfx/examples.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ Getting Started
55

66
### Run a command
77

8-
Establish an SSH connection and run a command:
9-
108
```cs
119
using (var client = new SshClient("sftp.foo.com", "guest", new PrivateKeyFile("path/to/my/key")))
1210
{
@@ -16,9 +14,7 @@ using (var client = new SshClient("sftp.foo.com", "guest", new PrivateKeyFile("p
1614
}
1715
```
1816

19-
### Upload and list files
20-
21-
SFTP Connection / Exchange
17+
### Upload and list files using SFTP
2218

2319
```cs
2420
using (var client = new SftpClient("sftp.foo.com", "guest", "pwd"))
@@ -39,7 +35,7 @@ using (var client = new SftpClient("sftp.foo.com", "guest", "pwd"))
3935

4036
### Multi-factor authentication
4137

42-
Establish an SFTP connection using both password and public-key authentication:
38+
Establish a connection using both password and public-key authentication:
4339

4440
```cs
4541
var connectionInfo = new ConnectionInfo("sftp.foo.com",
@@ -54,7 +50,7 @@ using (var client = new SftpClient(connectionInfo))
5450

5551
### Verify host identify
5652

57-
Establish an SSH connection using user name and password, and reject the connection if the fingerprint of the server does not match the expected fingerprint:
53+
Establish a connection using user name and password, and reject the connection if the fingerprint of the server does not match the expected fingerprint:
5854

5955
```cs
6056
string expectedFingerPrint = "LKOy5LvmtEe17S4lyxVXqvs7uPMy+yF79MQpHeCs/Qo";

src/Renci.SshNet/Common/AsyncResult.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ internal void EndInvoke()
9292
/// <summary>
9393
/// Gets a user-defined object that qualifies or contains information about an asynchronous operation.
9494
/// </summary>
95-
/// <returns>
95+
/// <value>
9696
/// A user-defined object that qualifies or contains information about an asynchronous operation.
97-
/// </returns>
97+
/// </value>
9898
public object AsyncState
9999
{
100100
get { return _asyncState; }
@@ -103,9 +103,9 @@ public object AsyncState
103103
/// <summary>
104104
/// Gets a value indicating whether the asynchronous operation completed synchronously.
105105
/// </summary>
106-
/// <returns>
106+
/// <value>
107107
/// <see langword="true"/> if the asynchronous operation completed synchronously; otherwise, <see langword="false"/>.
108-
/// </returns>
108+
/// </value>
109109
public bool CompletedSynchronously
110110
{
111111
get { return _completedState == StateCompletedSynchronously; }
@@ -114,9 +114,9 @@ public bool CompletedSynchronously
114114
/// <summary>
115115
/// Gets a <see cref="WaitHandle"/> that is used to wait for an asynchronous operation to complete.
116116
/// </summary>
117-
/// <returns>
117+
/// <value>
118118
/// A <see cref="WaitHandle"/> that is used to wait for an asynchronous operation to complete.
119-
/// </returns>
119+
/// </value>
120120
public WaitHandle AsyncWaitHandle
121121
{
122122
get
@@ -147,9 +147,9 @@ public WaitHandle AsyncWaitHandle
147147
/// <summary>
148148
/// Gets a value indicating whether the asynchronous operation has completed.
149149
/// </summary>
150-
/// <returns>
150+
/// <value>
151151
/// <see langword="true"/> if the operation is complete; otherwise, <see langword="false"/>.
152-
/// </returns>
152+
/// </value>
153153
public bool IsCompleted
154154
{
155155
get { return _completedState != StatePending; }

src/Renci.SshNet/Common/ChannelInputStream.cs

+19-19
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ protected override void Dispose(bool disposing)
153153
/// <summary>
154154
/// Gets a value indicating whether the current stream supports reading.
155155
/// </summary>
156-
/// <returns>
157-
/// true if the stream supports reading; otherwise, false.
158-
/// </returns>
156+
/// <value>
157+
/// <see langword="true"/> if the stream supports reading; otherwise, <see langword="false"/>.
158+
/// </value>
159159
public override bool CanRead
160160
{
161161
get { return false; }
@@ -164,9 +164,9 @@ public override bool CanRead
164164
/// <summary>
165165
/// Gets a value indicating whether the current stream supports seeking.
166166
/// </summary>
167-
/// <returns>
168-
/// <c>true</c> if the stream supports seeking; otherwise, <c>false</c>.
169-
/// </returns>
167+
/// <value>
168+
/// <see langword="true"/> if the stream supports seeking; otherwise, <see langword="false"/>.
169+
/// </value>
170170
public override bool CanSeek
171171
{
172172
get { return false; }
@@ -175,35 +175,35 @@ public override bool CanSeek
175175
/// <summary>
176176
/// Gets a value indicating whether the current stream supports writing.
177177
/// </summary>
178-
/// <returns>
179-
/// <c>true</c> if the stream supports writing; otherwise, <c>false</c>.
180-
/// </returns>
178+
/// <value>
179+
/// <see langword="true"/> if the stream supports writing; otherwise, <see langword="false"/>.
180+
/// </value>
181181
public override bool CanWrite
182182
{
183183
get { return true; }
184184
}
185185

186186
/// <summary>
187-
/// Gets the length in bytes of the stream.
187+
/// Throws <see cref="NotSupportedException"/>.
188188
/// </summary>
189-
/// <returns>
190-
/// A long value representing the length of the stream in bytes.
191-
/// </returns>
192-
/// <exception cref="NotSupportedException">A class derived from Stream does not support seeking.</exception>
193-
/// <exception cref="ObjectDisposedException">Methods were called after the stream was closed.</exception>
189+
/// <exception cref="NotSupportedException">Always.</exception>
190+
#pragma warning disable SA1623 // The property's documentation should begin with 'Gets or sets'
194191
public override long Length
192+
#pragma warning restore SA1623 // The property's documentation should begin with 'Gets or sets'
195193
{
196194
get { throw new NotSupportedException(); }
197195
}
198196

199197
/// <summary>
200-
/// Gets or sets the position within the current stream.
198+
/// Gets the position within the current stream.
201199
/// </summary>
202-
/// <returns>
200+
/// <value>
203201
/// The current position within the stream.
204-
/// </returns>
205-
/// <exception cref="NotSupportedException">The stream does not support seeking.</exception>
202+
/// </value>
203+
/// <exception cref="NotSupportedException">The setter is called.</exception>
204+
#pragma warning disable SA1623 // The property's documentation should begin with 'Gets or sets'
206205
public override long Position
206+
#pragma warning restore SA1623 // The property's documentation should begin with 'Gets or sets'
207207
{
208208
get { return _totalPosition; }
209209
set { throw new NotSupportedException(); }

src/Renci.SshNet/Common/PipeStream.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ protected override void Dispose(bool disposing)
163163
/// <summary>
164164
/// Gets a value indicating whether the current stream supports reading.
165165
/// </summary>
166-
/// <returns>
166+
/// <value>
167167
/// <see langword="true"/>.
168-
/// </returns>
168+
/// </value>
169169
/// <remarks>
170170
/// It is safe to read from <see cref="PipeStream"/> even after disposal.
171171
/// </remarks>
@@ -177,9 +177,9 @@ public override bool CanRead
177177
/// <summary>
178178
/// Gets a value indicating whether the current stream supports seeking.
179179
/// </summary>
180-
/// <returns>
180+
/// <value>
181181
/// <see langword="false"/>.
182-
/// </returns>
182+
/// </value>
183183
public override bool CanSeek
184184
{
185185
get { return false; }
@@ -188,10 +188,10 @@ public override bool CanSeek
188188
/// <summary>
189189
/// Gets a value indicating whether the current stream supports writing.
190190
/// </summary>
191-
/// <returns>
191+
/// <value>
192192
/// <see langword="true"/> if this stream has not been disposed and the underlying channel
193193
/// is still open, otherwise <see langword="false"/>.
194-
/// </returns>
194+
/// </value>
195195
/// <remarks>
196196
/// A value of <see langword="true"/> does not necessarily mean a write will succeed. It is possible
197197
/// that the stream is disposed by another thread between a call to <see cref="CanWrite"/> and the call to write.
@@ -204,7 +204,7 @@ public override bool CanWrite
204204
/// <summary>
205205
/// Gets the number of bytes currently available for reading.
206206
/// </summary>
207-
/// <returns>A long value representing the length of the stream in bytes.</returns>
207+
/// <value>A long value representing the length of the stream in bytes.</value>
208208
public override long Length
209209
{
210210
get
@@ -221,9 +221,9 @@ public override long Length
221221
/// This property always returns 0, and throws <see cref="NotSupportedException"/>
222222
/// when calling the setter.
223223
/// </summary>
224-
/// <returns>
224+
/// <value>
225225
/// 0.
226-
/// </returns>
226+
/// </value>
227227
/// <exception cref="NotSupportedException">The setter is called.</exception>
228228
#pragma warning disable SA1623 // The property's documentation should begin with 'Gets or sets'
229229
public override long Position

src/Renci.SshNet/Security/Cryptography/Cipher.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public abstract class Cipher
1616
/// <summary>
1717
/// Gets the size of the authentication tag for ciphers which implement Authenticated Encryption (AE).
1818
/// </summary>
19-
/// <returns>
19+
/// <value>
2020
/// When this <see cref="Cipher"/> implements Authenticated Encryption, the size, in bytes,
2121
/// of the authentication tag included in the encrypted message.
22-
/// </returns>
22+
/// </value>
2323
public virtual int TagSize { get; }
2424

2525
/// <summary>

src/Renci.SshNet/Security/Cryptography/RsaKey.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ public override int KeyLength
108108
/// <summary>
109109
/// Gets the digital signature implementation for this key.
110110
/// </summary>
111-
/// <returns>
111+
/// <value>
112112
/// An implementation of an RSA digital signature using the SHA-1 hash algorithm.
113-
/// </returns>
113+
/// </value>
114114
protected internal override DigitalSignature DigitalSignature
115115
{
116116
get

0 commit comments

Comments
 (0)