# < Summary

Information

Class: | Renci.SshNet.SshClient
Assembly: | Renci.SshNet
File(s): | \home\appveyor\projects\ssh-net\src\Renci.SshNet\SshClient.cs

Line coverage
87%

Covered lines: | 116
Uncovered lines: | 16
Coverable lines: | 132
Total lines: | 526
Line coverage: | 87.8%

Branch coverage
80%

Covered branches: | 16
Total branches: | 20
Branch coverage: | 80%

Method coverage

Feature is only available for sponsors

Upgrade to PRO version

# Metrics

Method | Branch coverage | Cyclomatic complexity | Line coverage
--- | --- | --- | ---
get_ForwardedPorts() | 100% | 1 | 100%
.ctor(...) | 100% | 1 | 100%
.ctor(...) | 100% | 1 | 100%
.ctor(...) | 100% | 1 | 100%
.ctor(...) | 100% | 1 | 0%
.ctor(...) | 100% | 1 | 0%
.ctor(...) | 100% | 1 | 100%
.ctor(...) | 100% | 1 | 100%
OnDisconnecting() | 100% | 2 | 100%
AddForwardedPort(...) | 50% | 2 | 75%
RemoveForwardedPort(...) | 50% | 2 | 75%
AttachForwardedPort(...) | 50% | 4 | 66.66%
DetachForwardedPort(...) | 100% | 1 | 100%
CreateCommand(...) | 100% | 1 | 100%
CreateCommand(...) | 100% | 1 | 100%
RunCommand(...) | 100% | 1 | 100%
CreateShell(...) | 100% | 1 | 100%
CreateShell(...) | 100% | 1 | 66.66%
CreateShell(...) | 100% | 1 | 100%
CreateShell(...) | 100% | 1 | 90%
CreateShell(...) | 100% | 1 | 66.66%
CreateShell(...) | 100% | 1 | 66.66%
CreateShellStream(...) | 100% | 1 | 100%
CreateShellStream(...) | 100% | 1 | 100%
OnDisconnected() | 100% | 2 | 100%
Dispose(...) | 100% | 6 | 100%
EnsureSessionIsOpen() | 100% | 2 | 100%

# File(s)

## \home\appveyor\projects\ssh-net\src\Renci.SshNet\SshClient.cs

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System;`
|  | `2` |  | `using System.Collections.Generic;`
|  | `3` |  | `using System.Diagnostics.CodeAnalysis;`
|  | `4` |  | `using System.IO;`
|  | `5` |  | `using System.Net;`
|  | `6` |  | `using System.Text;`
|  | `7` |  | ``
|  | `8` |  | `using Renci.SshNet.Common;`
|  | `9` |  | ``
|  | `10` |  | `namespace Renci.SshNet`
|  | `11` |  | `{`
|  | `12` |  | `/// <summary>`
|  | `13` |  | `/// Provides client connection to SSH server.`
|  | `14` |  | `/// </summary>`
|  | `15` |  | `public class SshClient : BaseClient`
|  | `16` |  | `{`
|  | `17` |  | `/// <summary>`
|  | `18` |  | `/// Holds the list of forwarded ports.`
|  | `19` |  | `/// </summary>`
|  | `20` |  | `private readonly List<ForwardedPort> _forwardedPorts;`
|  | `21` |  | ``
|  | `22` |  | `/// <summary>`
|  | `23` |  | `/// Holds a value indicating whether the current instance is disposed.`
|  | `24` |  | `/// </summary>`
|  | `25` |  | `/// <value>`
|  | `26` |  | `/// <see langword="true"/> if the current instance is disposed; otherwise, <see langword="false"/>.`
|  | `27` |  | `/// </value>`
|  | `28` |  | `private bool _isDisposed;`
|  | `29` |  | ``
|  | `30` |  | `private MemoryStream _inputStream;`
|  | `31` |  | ``
|  | `32` |  | `/// <summary>`
|  | `33` |  | `/// Gets the list of forwarded ports.`
|  | `34` |  | `/// </summary>`
|  | `35` |  | `public IEnumerable<ForwardedPort> ForwardedPorts`
|  | `36` |  | `{`
|  | `37` |  | `get`
| 6 | `38` |  | `{`
| 6 | `39` |  | `return _forwardedPorts.AsReadOnly();`
| 6 | `40` |  | `}`
|  | `41` |  | `}`
|  | `42` |  | ``
|  | `43` |  | `/// <summary>`
|  | `44` |  | `/// Initializes a new instance of the <see cref="SshClient" /> class.`
|  | `45` |  | `/// </summary>`
|  | `46` |  | `/// <param name="connectionInfo">The connection info.</param>`
|  | `47` |  | `/// <example>`
|  | `48` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\PasswordConnectionInfoTest.cs" region="Example Passwo`
|  | `49` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\PasswordConnectionInfoTest.cs" region="Example Passwo`
|  | `50` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\PrivateKeyConnectionInfoTest.cs" region="Example Priv`
|  | `51` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\SshClientTest.cs" region="Example SshClient Connect T`
|  | `52` |  | `/// </example>`
|  | `53` |  | `/// <exception cref="ArgumentNullException"><paramref name="connectionInfo"/> is <see langword="null"/>.</except`
|  | `54` |  | `public SshClient(ConnectionInfo connectionInfo)`
| 231 | `55` |  | `: this(connectionInfo, ownsConnectionInfo: false)`
| 231 | `56` |  | `{`
| 231 | `57` |  | `}`
|  | `58` |  | ``
|  | `59` |  | `/// <summary>`
|  | `60` |  | `/// Initializes a new instance of the <see cref="SshClient"/> class.`
|  | `61` |  | `/// </summary>`
|  | `62` |  | `/// <param name="host">Connection host.</param>`
|  | `63` |  | `/// <param name="port">Connection port.</param>`
|  | `64` |  | `/// <param name="username">Authentication username.</param>`
|  | `65` |  | `/// <param name="password">Authentication password.</param>`
|  | `66` |  | `/// <exception cref="ArgumentNullException"><paramref name="password"/> is <see langword="null"/>.</exception>`
|  | `67` |  | `/// <exception cref="ArgumentException"><paramref name="host"/> is invalid, or <paramref name="username"/> is <s`
|  | `68` |  | `/// <exception cref="ArgumentOutOfRangeException"><paramref name="port"/> is not within <see cref="IPEndPoint.Mi`
|  | `69` |  | `[SuppressMessage("Microsoft.Reliability", "C2A000:DisposeObjectsBeforeLosingScope", Justification = "Disposed in`
|  | `70` |  | `public SshClient(string host, int port, string username, string password)`
|  | `71` |  | `#pragma warning disable CA2000 // Dispose objects before losing scope`
| 97 | `72` |  | `: this(new PasswordConnectionInfo(host, port, username, password), ownsConnectionInfo: true)`
|  | `73` |  | `#pragma warning restore CA2000 // Dispose objects before losing scope`
| 97 | `74` |  | `{`
| 97 | `75` |  | `}`
|  | `76` |  | ``
|  | `77` |  | `/// <summary>`
|  | `78` |  | `/// Initializes a new instance of the <see cref="SshClient"/> class.`
|  | `79` |  | `/// </summary>`
|  | `80` |  | `/// <param name="host">Connection host.</param>`
|  | `81` |  | `/// <param name="username">Authentication username.</param>`
|  | `82` |  | `/// <param name="password">Authentication password.</param>`
|  | `83` |  | `/// <example>`
|  | `84` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\SshClientTest.cs" region="Example SshClient(host, use`
|  | `85` |  | `/// </example>`
|  | `86` |  | `/// <exception cref="ArgumentNullException"><paramref name="password"/> is <see langword="null"/>.</exception>`
|  | `87` |  | `/// <exception cref="ArgumentException"><paramref name="host"/> is invalid, or <paramref name="username"/> is <s`
|  | `88` |  | `public SshClient(string host, string username, string password)`
| 39 | `89` |  | `: this(host, ConnectionInfo.DefaultPort, username, password)`
| 39 | `90` |  | `{`
| 39 | `91` |  | `}`
|  | `92` |  | ``
|  | `93` |  | `/// <summary>`
|  | `94` |  | `/// Initializes a new instance of the <see cref="SshClient"/> class.`
|  | `95` |  | `/// </summary>`
|  | `96` |  | `/// <param name="host">Connection host.</param>`
|  | `97` |  | `/// <param name="port">Connection port.</param>`
|  | `98` |  | `/// <param name="username">Authentication username.</param>`
|  | `99` |  | `/// <param name="keyFiles">Authentication private key file(s) .</param>`
|  | `100` |  | `/// <example>`
|  | `101` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\SshClientTest.cs" region="Example SshClient(host, use`
|  | `102` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\SshClientTest.cs" region="Example SshClient(host, use`
|  | `103` |  | `/// </example>`
|  | `104` |  | `/// <exception cref="ArgumentNullException"><paramref name="keyFiles"/> is <see langword="null"/>.</exception>`
|  | `105` |  | `/// <exception cref="ArgumentException"><paramref name="host"/> is invalid, -or- <paramref name="username"/> is`
|  | `106` |  | `/// <exception cref="ArgumentOutOfRangeException"><paramref name="port"/> is not within <see cref="IPEndPoint.Mi`
|  | `107` |  | `[SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope", Justification = "Disposed in`
|  | `108` |  | `public SshClient(string host, int port, string username, params IPrivateKeySource[] keyFiles)`
| 0 | `109` |  | `: this(new PrivateKeyConnectionInfo(host, port, username, keyFiles), ownsConnectionInfo: true)`
| 0 | `110` |  | `{`
| 0 | `111` |  | `}`
|  | `112` |  | ``
|  | `113` |  | `/// <summary>`
|  | `114` |  | `/// Initializes a new instance of the <see cref="SshClient"/> class.`
|  | `115` |  | `/// </summary>`
|  | `116` |  | `/// <param name="host">Connection host.</param>`
|  | `117` |  | `/// <param name="username">Authentication username.</param>`
|  | `118` |  | `/// <param name="keyFiles">Authentication private key file(s) .</param>`
|  | `119` |  | `/// <example>`
|  | `120` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\SshClientTest.cs" region="Example SshClient(host, use`
|  | `121` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\SshClientTest.cs" region="Example SshClient(host, use`
|  | `122` |  | `/// </example>`
|  | `123` |  | `/// <exception cref="ArgumentNullException"><paramref name="keyFiles"/> is <see langword="null"/>.</exception>`
|  | `124` |  | `/// <exception cref="ArgumentException"><paramref name="host"/> is invalid, -or- <paramref name="username"/> is`
|  | `125` |  | `public SshClient(string host, string username, params IPrivateKeySource[] keyFiles)`
| 0 | `126` |  | `: this(host, ConnectionInfo.DefaultPort, username, keyFiles)`
| 0 | `127` |  | `{`
| 0 | `128` |  | `}`
|  | `129` |  | ``
|  | `130` |  | `/// <summary>`
|  | `131` |  | `/// Initializes a new instance of the <see cref="SshClient"/> class.`
|  | `132` |  | `/// </summary>`
|  | `133` |  | `/// <param name="connectionInfo">The connection info.</param>`
|  | `134` |  | `/// <param name="ownsConnectionInfo">Specified whether this instance owns the connection info.</param>`
|  | `135` |  | `/// <exception cref="ArgumentNullException"><paramref name="connectionInfo"/> is <see langword="null"/>.</except`
|  | `136` |  | `/// <remarks>`
|  | `137` |  | `/// If <paramref name="ownsConnectionInfo"/> is <see langword="true"/>, then the`
|  | `138` |  | `/// connection info will be disposed when this instance is disposed.`
|  | `139` |  | `/// </remarks>`
|  | `140` |  | `private SshClient(ConnectionInfo connectionInfo, bool ownsConnectionInfo)`
| 328 | `141` |  | `: this(connectionInfo, ownsConnectionInfo, new ServiceFactory())`
| 328 | `142` |  | `{`
| 328 | `143` |  | `}`
|  | `144` |  | ``
|  | `145` |  | `/// <summary>`
|  | `146` |  | `/// Initializes a new instance of the <see cref="SshClient"/> class.`
|  | `147` |  | `/// </summary>`
|  | `148` |  | `/// <param name="connectionInfo">The connection info.</param>`
|  | `149` |  | `/// <param name="ownsConnectionInfo">Specified whether this instance owns the connection info.</param>`
|  | `150` |  | `/// <param name="serviceFactory">The factory to use for creating new services.</param>`
|  | `151` |  | `/// <exception cref="ArgumentNullException"><paramref name="connectionInfo"/> is <see langword="null"/>.</except`
|  | `152` |  | `/// <exception cref="ArgumentNullException"><paramref name="serviceFactory"/> is <see langword="null"/>.</except`
|  | `153` |  | `/// <remarks>`
|  | `154` |  | `/// If <paramref name="ownsConnectionInfo"/> is <see langword="true"/>, then the`
|  | `155` |  | `/// connection info will be disposed when this instance is disposed.`
|  | `156` |  | `/// </remarks>`
|  | `157` |  | `internal SshClient(ConnectionInfo connectionInfo, bool ownsConnectionInfo, IServiceFactory serviceFactory)`
| 412 | `158` |  | `: base(connectionInfo, ownsConnectionInfo, serviceFactory)`
| 412 | `159` |  | `{`
| 412 | `160` |  | `_forwardedPorts = new List<ForwardedPort>();`
| 412 | `161` |  | `}`
|  | `162` |  | ``
|  | `163` |  | `/// <summary>`
|  | `164` |  | `/// Called when client is disconnecting from the server.`
|  | `165` |  | `/// </summary>`
|  | `166` |  | `protected override void OnDisconnecting()`
| 500 | `167` |  | `{`
| 500 | `168` |  | `base.OnDisconnecting();`
|  | `169` |  | ``
| 1564 | `170` |  | `foreach (var port in _forwardedPorts)`
| 32 | `171` |  | `{`
| 32 | `172` |  | `port.Stop();`
| 32 | `173` |  | `}`
| 500 | `174` |  | `}`
|  | `175` |  | ``
|  | `176` |  | `/// <summary>`
|  | `177` |  | `/// Adds the forwarded port.`
|  | `178` |  | `/// </summary>`
|  | `179` |  | `/// <param name="port">The port.</param>`
|  | `180` |  | `/// <example>`
|  | `181` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\ForwardedPortRemoteTest.cs" region="Example SshClient`
|  | `182` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\ForwardedPortLocalTest.cs" region="Example SshClient`
|  | `183` |  | `/// </example>`
|  | `184` |  | `/// <exception cref="InvalidOperationException">Forwarded port is already added to a different client.</exceptio`
|  | `185` |  | `/// <exception cref="ArgumentNullException"><paramref name="port"/> is <see langword="null"/>.</exception>`
|  | `186` |  | `/// <exception cref="SshConnectionException">Client is not connected.</exception>`
|  | `187` |  | `public void AddForwardedPort(ForwardedPort port)`
| 40 | `188` |  | `{`
| 40 | `189` |  | `if (port is null)`
| 0 | `190` |  | `{`
| 0 | `191` |  | `throw new ArgumentNullException(nameof(port));`
|  | `192` |  | `}`
|  | `193` |  | ``
| 40 | `194` |  | `EnsureSessionIsOpen();`
|  | `195` |  | ``
| 36 | `196` |  | `AttachForwardedPort(port);`
| 36 | `197` |  | `_forwardedPorts.Add(port);`
| 36 | `198` |  | `}`
|  | `199` |  | ``
|  | `200` |  | `/// <summary>`
|  | `201` |  | `/// Stops and removes the forwarded port from the list.`
|  | `202` |  | `/// </summary>`
|  | `203` |  | `/// <param name="port">Forwarded port.</param>`
|  | `204` |  | `/// <exception cref="ArgumentNullException"><paramref name="port"/> is <see langword="null"/>.</exception>`
|  | `205` |  | `public void RemoveForwardedPort(ForwardedPort port)`
| 4 | `206` |  | `{`
| 4 | `207` |  | `if (port is null)`
| 0 | `208` |  | `{`
| 0 | `209` |  | `throw new ArgumentNullException(nameof(port));`
|  | `210` |  | `}`
|  | `211` |  | ``
|  | `212` |  | `// Stop port forwarding before removing it`
| 4 | `213` |  | `port.Stop();`
|  | `214` |  | ``
| 4 | `215` |  | `DetachForwardedPort(port);`
| 4 | `216` |  | `_ = _forwardedPorts.Remove(port);`
| 4 | `217` |  | `}`
|  | `218` |  | ``
|  | `219` |  | `private void AttachForwardedPort(ForwardedPort port)`
| 36 | `220` |  | `{`
| 36 | `221` |  | `if (port.Session != null && port.Session != Session)`
| 0 | `222` |  | `{`
| 0 | `223` |  | `throw new InvalidOperationException("Forwarded port is already added to a different client.");`
|  | `224` |  | `}`
|  | `225` |  | ``
| 36 | `226` |  | `port.Session = Session;`
| 36 | `227` |  | `}`
|  | `228` |  | ``
|  | `229` |  | `private static void DetachForwardedPort(ForwardedPort port)`
| 36 | `230` |  | `{`
| 36 | `231` |  | `port.Session = null;`
| 36 | `232` |  | `}`
|  | `233` |  | ``
|  | `234` |  | `/// <summary>`
|  | `235` |  | `/// Creates the command to be executed.`
|  | `236` |  | `/// </summary>`
|  | `237` |  | `/// <param name="commandText">The command text.</param>`
|  | `238` |  | `/// <returns><see cref="SshCommand"/> object.</returns>`
|  | `239` |  | `/// <exception cref="SshConnectionException">Client is not connected.</exception>`
|  | `240` |  | `public SshCommand CreateCommand(string commandText)`
| 724 | `241` |  | `{`
| 724 | `242` |  | `return CreateCommand(commandText, ConnectionInfo.Encoding);`
| 715 | `243` |  | `}`
|  | `244` |  | ``
|  | `245` |  | `/// <summary>`
|  | `246` |  | `/// Creates the command to be executed with specified encoding.`
|  | `247` |  | `/// </summary>`
|  | `248` |  | `/// <param name="commandText">The command text.</param>`
|  | `249` |  | `/// <param name="encoding">The encoding to use for results.</param>`
|  | `250` |  | `/// <returns><see cref="SshCommand"/> object which uses specified encoding.</returns>`
|  | `251` |  | `/// <remarks>This method will change current default encoding.</remarks>`
|  | `252` |  | `/// <exception cref="SshConnectionException">Client is not connected.</exception>`
|  | `253` |  | `/// <exception cref="ArgumentNullException"><paramref name="commandText"/> or <paramref name="encoding"/> is <se`
|  | `254` |  | `public SshCommand CreateCommand(string commandText, Encoding encoding)`
| 727 | `255` |  | `{`
| 727 | `256` |  | `EnsureSessionIsOpen();`
|  | `257` |  | ``
| 715 | `258` |  | `ConnectionInfo.Encoding = encoding;`
| 715 | `259` |  | `return new SshCommand(Session, commandText, encoding);`
| 715 | `260` |  | `}`
|  | `261` |  | ``
|  | `262` |  | `/// <summary>`
|  | `263` |  | `/// Creates and executes the command.`
|  | `264` |  | `/// </summary>`
|  | `265` |  | `/// <param name="commandText">The command text.</param>`
|  | `266` |  | `/// <returns>Returns an instance of <see cref="SshCommand"/> with execution results.</returns>`
|  | `267` |  | `/// <remarks>This method internally uses asynchronous calls.</remarks>`
|  | `268` |  | `/// <example>`
|  | `269` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\SshCommandTest.cs" region="Example SshCommand RunComm`
|  | `270` |  | `/// <code source="..\..\src\Renci.SshNet.Tests\Classes\SshCommandTest.cs" region="Example SshCommand RunComm`
|  | `271` |  | `/// </example>`
|  | `272` |  | `/// <exception cref="ArgumentException">CommandText property is empty.</exception>`
|  | `273` |  | `/// <exception cref="SshException">Invalid Operation - An existing channel was used to execute this command.</ex`
|  | `274` |  | `/// <exception cref="InvalidOperationException">Asynchronous operation is already in progress.</exception>`
|  | `275` |  | `/// <exception cref="SshConnectionException">Client is not connected.</exception>`
|  | `276` |  | `/// <exception cref="ArgumentNullException"><paramref name="commandText"/> is <see langword="null"/>.</exception`
|  | `277` |  | `public SshCommand RunCommand(string commandText)`
| 163 | `278` |  | `{`
| 163 | `279` |  | `var cmd = CreateCommand(commandText);`
| 160 | `280` |  | `_ = cmd.Execute();`
| 160 | `281` |  | `return cmd;`
| 160 | `282` |  | `}`
|  | `283` |  | ``
|  | `284` |  | `/// <summary>`
|  | `285` |  | `/// Creates the shell.`
|  | `286` |  | `/// </summary>`
|  | `287` |  | `/// <param name="input">The input.</param>`
|  | `288` |  | `/// <param name="output">The output.</param>`
|  | `289` |  | `/// <param name="extendedOutput">The extended output.</param>`
|  | `290` |  | `/// <param name="terminalName">Name of the terminal.</param>`
|  | `291` |  | `/// <param name="columns">The columns.</param>`
|  | `292` |  | `/// <param name="rows">The rows.</param>`
|  | `293` |  | `/// <param name="width">The width.</param>`
|  | `294` |  | `/// <param name="height">The height.</param>`
|  | `295` |  | `/// <param name="terminalModes">The terminal mode.</param>`
|  | `296` |  | `/// <param name="bufferSize">Size of the internal read buffer.</param>`
|  | `297` |  | `/// <returns>`
|  | `298` |  | `/// Returns a representation of a <see cref="Shell" /> object.`
|  | `299` |  | `/// </returns>`
|  | `300` |  | `/// <exception cref="SshConnectionException">Client is not connected.</exception>`
|  | `301` |  | `public Shell CreateShell(Stream input, Stream output, Stream extendedOutput, string terminalName, uint columns,`
| 19 | `302` |  | `{`
| 19 | `303` |  | `EnsureSessionIsOpen();`
|  | `304` |  | ``
| 1 | `305` |  | `return new Shell(Session, input, output, extendedOutput, terminalName, columns, rows, width, height, termina`
| 1 | `306` |  | `}`
|  | `307` |  | ``
|  | `308` |  | `/// <summary>`
|  | `309` |  | `/// Creates the shell.`
|  | `310` |  | `/// </summary>`
|  | `311` |  | `/// <param name="input">The input.</param>`
|  | `312` |  | `/// <param name="output">The output.</param>`
|  | `313` |  | `/// <param name="extendedOutput">The extended output.</param>`
|  | `314` |  | `/// <param name="terminalName">Name of the terminal.</param>`
|  | `315` |  | `/// <param name="columns">The columns.</param>`
|  | `316` |  | `/// <param name="rows">The rows.</param>`
|  | `317` |  | `/// <param name="width">The width.</param>`
|  | `318` |  | `/// <param name="height">The height.</param>`
|  | `319` |  | `/// <param name="terminalModes">The terminal mode.</param>`
|  | `320` |  | `/// <returns>`
|  | `321` |  | `/// Returns a representation of a <see cref="Shell" /> object.`
|  | `322` |  | `/// </returns>`
|  | `323` |  | `/// <exception cref="SshConnectionException">Client is not connected.</exception>`
|  | `324` |  | `public Shell CreateShell(Stream input, Stream output, Stream extendedOutput, string terminalName, uint columns,`
| 3 | `325` |  | `{`
| 3 | `326` |  | `return CreateShell(input, output, extendedOutput, terminalName, columns, rows, width, height, terminalModes,`
| 0 | `327` |  | `}`
|  | `328` |  | ``
|  | `329` |  | `/// <summary>`
|  | `330` |  | `/// Creates the shell.`
|  | `331` |  | `/// </summary>`
|  | `332` |  | `/// <param name="input">The input.</param>`
|  | `333` |  | `/// <param name="output">The output.</param>`
|  | `334` |  | `/// <param name="extendedOutput">The extended output.</param>`
|  | `335` |  | `/// <returns>`
|  | `336` |  | `/// Returns a representation of a <see cref="Shell" /> object.`
|  | `337` |  | `/// </returns>`
|  | `338` |  | `/// <exception cref="SshConnectionException">Client is not connected.</exception>`
|  | `339` |  | `public Shell CreateShell(Stream input, Stream output, Stream extendedOutput)`
| 4 | `340` |  | `{`
| 4 | `341` |  | `return CreateShell(input, output, extendedOutput, string.Empty, 0, 0, 0, 0, terminalModes: null, 1024);`
| 1 | `342` |  | `}`
|  | `343` |  | ``
|  | `344` |  | `/// <summary>`
|  | `345` |  | `/// Creates the shell.`
|  | `346` |  | `/// </summary>`
|  | `347` |  | `/// <param name="encoding">The encoding to use to send the input.</param>`
|  | `348` |  | `/// <param name="input">The input.</param>`
|  | `349` |  | `/// <param name="output">The output.</param>`
|  | `350` |  | `/// <param name="extendedOutput">The extended output.</param>`
|  | `351` |  | `/// <param name="terminalName">Name of the terminal.</param>`
|  | `352` |  | `/// <param name="columns">The columns.</param>`
|  | `353` |  | `/// <param name="rows">The rows.</param>`
|  | `354` |  | `/// <param name="width">The width.</param>`
|  | `355` |  | `/// <param name="height">The height.</param>`
|  | `356` |  | `/// <param name="terminalModes">The terminal mode.</param>`
|  | `357` |  | `/// <param name="bufferSize">Size of the internal read buffer.</param>`
|  | `358` |  | `/// <returns>`
|  | `359` |  | `/// Returns a representation of a <see cref="Shell" /> object.`
|  | `360` |  | `/// </returns>`
|  | `361` |  | `/// <exception cref="SshConnectionException">Client is not connected.</exception>`
|  | `362` |  | `public Shell CreateShell(Encoding encoding, string input, Stream output, Stream extendedOutput, string terminalN`
| 9 | `363` |  | `{`
|  | `364` |  | `/*`
|  | `365` |  | `* TODO Issue #1224: let shell dispose of input stream when we own the stream!`
|  | `366` |  | `*/`
|  | `367` |  | ``
| 9 | `368` |  | `_inputStream = new MemoryStream();`
|  | `369` |  | ``
| 9 | `370` |  | `using (var writer = new StreamWriter(_inputStream, encoding, bufferSize: 1024, leaveOpen: true))`
| 9 | `371` |  | `{`
| 9 | `372` |  | `writer.Write(input);`
| 9 | `373` |  | `writer.Flush();`
| 9 | `374` |  | `}`
|  | `375` |  | ``
| 9 | `376` |  | `_ = _inputStream.Seek(0, SeekOrigin.Begin);`
|  | `377` |  | ``
| 9 | `378` |  | `return CreateShell(_inputStream, output, extendedOutput, terminalName, columns, rows, width, height, termina`
| 0 | `379` |  | `}`
|  | `380` |  | ``
|  | `381` |  | `/// <summary>`
|  | `382` |  | `/// Creates the shell.`
|  | `383` |  | `/// </summary>`
|  | `384` |  | `/// <param name="encoding">The encoding.</param>`
|  | `385` |  | `/// <param name="input">The input.</param>`
|  | `386` |  | `/// <param name="output">The output.</param>`
|  | `387` |  | `/// <param name="extendedOutput">The extended output.</param>`
|  | `388` |  | `/// <param name="terminalName">Name of the terminal.</param>`
|  | `389` |  | `/// <param name="columns">The columns.</param>`
|  | `390` |  | `/// <param name="rows">The rows.</param>`
|  | `391` |  | `/// <param name="width">The width.</param>`
|  | `392` |  | `/// <param name="height">The height.</param>`
|  | `393` |  | `/// <param name="terminalModes">The terminal modes.</param>`
|  | `394` |  | `/// <returns>`
|  | `395` |  | `/// Returns a representation of a <see cref="Shell" /> object.`
|  | `396` |  | `/// </returns>`
|  | `397` |  | `/// <exception cref="SshConnectionException">Client is not connected.</exception>`
|  | `398` |  | `public Shell CreateShell(Encoding encoding, string input, Stream output, Stream extendedOutput, string terminalN`
| 3 | `399` |  | `{`
| 3 | `400` |  | `return CreateShell(encoding, input, output, extendedOutput, terminalName, columns, rows, width, height, term`
| 0 | `401` |  | `}`
|  | `402` |  | ``
|  | `403` |  | `/// <summary>`
|  | `404` |  | `/// Creates the shell.`
|  | `405` |  | `/// </summary>`
|  | `406` |  | `/// <param name="encoding">The encoding.</param>`
|  | `407` |  | `/// <param name="input">The input.</param>`
|  | `408` |  | `/// <param name="output">The output.</param>`
|  | `409` |  | `/// <param name="extendedOutput">The extended output.</param>`
|  | `410` |  | `/// <returns>`
|  | `411` |  | `/// Returns a representation of a <see cref="Shell" /> object.`
|  | `412` |  | `/// </returns>`
|  | `413` |  | `/// <exception cref="SshConnectionException">Client is not connected.</exception>`
|  | `414` |  | `public Shell CreateShell(Encoding encoding, string input, Stream output, Stream extendedOutput)`
| 3 | `415` |  | `{`
| 3 | `416` |  | `return CreateShell(encoding, input, output, extendedOutput, string.Empty, 0, 0, 0, 0, terminalModes: null, 1`
| 0 | `417` |  | `}`
|  | `418` |  | ``
|  | `419` |  | `/// <summary>`
|  | `420` |  | `/// Creates the shell stream.`
|  | `421` |  | `/// </summary>`
|  | `422` |  | `/// <param name="terminalName">The <c>TERM</c> environment variable.</param>`
|  | `423` |  | `/// <param name="columns">The terminal width in columns.</param>`
|  | `424` |  | `/// <param name="rows">The terminal width in rows.</param>`
|  | `425` |  | `/// <param name="width">The terminal width in pixels.</param>`
|  | `426` |  | `/// <param name="height">The terminal height in pixels.</param>`
|  | `427` |  | `/// <param name="bufferSize">The size of the buffer.</param>`
|  | `428` |  | `/// <returns>`
|  | `429` |  | `/// The created <see cref="ShellStream"/> instance.`
|  | `430` |  | `/// </returns>`
|  | `431` |  | `/// <exception cref="SshConnectionException">Client is not connected.</exception>`
|  | `432` |  | `/// <remarks>`
|  | `433` |  | `/// <para>`
|  | `434` |  | `/// The <c>TERM</c> environment variable contains an identifier for the text window's capabilities.`
|  | `435` |  | `/// You can get a detailed list of these cababilities by using the ‘infocmp’ command.`
|  | `436` |  | `/// </para>`
|  | `437` |  | `/// <para>`
|  | `438` |  | `/// The column/row dimensions override the pixel dimensions(when nonzero). Pixel dimensions refer`
|  | `439` |  | `/// to the drawable area of the window.`
|  | `440` |  | `/// </para>`
|  | `441` |  | `/// </remarks>`
|  | `442` |  | `public ShellStream CreateShellStream(string terminalName, uint columns, uint rows, uint width, uint height, int`
| 14 | `443` |  | `{`
| 14 | `444` |  | `return CreateShellStream(terminalName, columns, rows, width, height, bufferSize, terminalModeValues: null);`
| 11 | `445` |  | `}`
|  | `446` |  | ``
|  | `447` |  | `/// <summary>`
|  | `448` |  | `/// Creates the shell stream.`
|  | `449` |  | `/// </summary>`
|  | `450` |  | `/// <param name="terminalName">The <c>TERM</c> environment variable.</param>`
|  | `451` |  | `/// <param name="columns">The terminal width in columns.</param>`
|  | `452` |  | `/// <param name="rows">The terminal width in rows.</param>`
|  | `453` |  | `/// <param name="width">The terminal width in pixels.</param>`
|  | `454` |  | `/// <param name="height">The terminal height in pixels.</param>`
|  | `455` |  | `/// <param name="bufferSize">The size of the buffer.</param>`
|  | `456` |  | `/// <param name="terminalModeValues">The terminal mode values.</param>`
|  | `457` |  | `/// <returns>`
|  | `458` |  | `/// The created <see cref="ShellStream"/> instance.`
|  | `459` |  | `/// </returns>`
|  | `460` |  | `/// <exception cref="SshConnectionException">Client is not connected.</exception>`
|  | `461` |  | `/// <remarks>`
|  | `462` |  | `/// <para>`
|  | `463` |  | `/// The <c>TERM</c> environment variable contains an identifier for the text window's capabilities.`
|  | `464` |  | `/// You can get a detailed list of these cababilities by using the ‘infocmp’ command.`
|  | `465` |  | `/// </para>`
|  | `466` |  | `/// <para>`
|  | `467` |  | `/// The column/row dimensions override the pixel dimensions(when non-zero). Pixel dimensions refer`
|  | `468` |  | `/// to the drawable area of the window.`
|  | `469` |  | `/// </para>`
|  | `470` |  | `/// </remarks>`
|  | `471` |  | `public ShellStream CreateShellStream(string terminalName, uint columns, uint rows, uint width, uint height, int`
| 24 | `472` |  | `{`
| 24 | `473` |  | `EnsureSessionIsOpen();`
|  | `474` |  | ``
| 18 | `475` |  | `return ServiceFactory.CreateShellStream(Session, terminalName, columns, rows, width, height, terminalModeVal`
| 18 | `476` |  | `}`
|  | `477` |  | ``
|  | `478` |  | `/// <summary>`
|  | `479` |  | `/// Stops forwarded ports.`
|  | `480` |  | `/// </summary>`
|  | `481` |  | `protected override void OnDisconnected()`
| 500 | `482` |  | `{`
| 500 | `483` |  | `base.OnDisconnected();`
|  | `484` |  | ``
| 1064 | `485` |  | `for (var i = _forwardedPorts.Count - 1; i >= 0; i--)`
| 32 | `486` |  | `{`
| 32 | `487` |  | `var port = _forwardedPorts[i];`
| 32 | `488` |  | `DetachForwardedPort(port);`
| 32 | `489` |  | `_forwardedPorts.RemoveAt(i);`
| 32 | `490` |  | `}`
| 500 | `491` |  | `}`
|  | `492` |  | ``
|  | `493` |  | `/// <summary>`
|  | `494` |  | `/// Releases unmanaged and - optionally - managed resources.`
|  | `495` |  | `/// </summary>`
|  | `496` |  | `/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langwor`
|  | `497` |  | `protected override void Dispose(bool disposing)`
| 427 | `498` |  | `{`
| 427 | `499` |  | `base.Dispose(disposing);`
|  | `500` |  | ``
| 427 | `501` |  | `if (_isDisposed)`
| 15 | `502` |  | `{`
| 15 | `503` |  | `return;`
|  | `504` |  | `}`
|  | `505` |  | ``
| 412 | `506` |  | `if (disposing)`
| 388 | `507` |  | `{`
| 388 | `508` |  | `if (_inputStream != null)`
| 9 | `509` |  | `{`
| 9 | `510` |  | `_inputStream.Dispose();`
| 9 | `511` |  | `_inputStream = null;`
| 9 | `512` |  | `}`
|  | `513` |  | ``
| 388 | `514` |  | `_isDisposed = true;`
| 388 | `515` |  | `}`
| 427 | `516` |  | `}`
|  | `517` |  | ``
|  | `518` |  | `private void EnsureSessionIsOpen()`
| 810 | `519` |  | `{`
| 810 | `520` |  | `if (Session is null)`
| 40 | `521` |  | `{`
| 40 | `522` |  | `throw new SshConnectionException("Client not connected.");`
|  | `523` |  | `}`
| 770 | `524` |  | `}`
|  | `525` |  | `}`
|  | `526` |  | `}`

# Methods/Properties

get_ForwardedPorts()
.ctor(Renci.SshNet.ConnectionInfo)
.ctor(System.String,System.Int32,System.String,System.String)
.ctor(System.String,System.String,System.String)
.ctor(System.String,System.Int32,System.String,Renci.SshNet.IPrivateKeySource[])
.ctor(System.String,System.String,Renci.SshNet.IPrivateKeySource[])
.ctor(Renci.SshNet.ConnectionInfo,System.Boolean)
.ctor(Renci.SshNet.ConnectionInfo,System.Boolean,Renci.SshNet.IServiceFactory)
OnDisconnecting()
AddForwardedPort(Renci.SshNet.ForwardedPort)
RemoveForwardedPort(Renci.SshNet.ForwardedPort)
AttachForwardedPort(Renci.SshNet.ForwardedPort)
DetachForwardedPort(Renci.SshNet.ForwardedPort)
CreateCommand(System.String)
CreateCommand(System.String,System.Text.Encoding)
RunCommand(System.String)
CreateShell(System.IO.Stream,System.IO.Stream,System.IO.Stream,System.String,System.UInt32,System.UInt32,System.UInt32,System.UInt32,System.Collections.Generic.IDictionary`2<Renci.SshNet.Common.TerminalModes,System.UInt32>,System.Int32)
CreateShell(System.IO.Stream,System.IO.Stream,System.IO.Stream,System.String,System.UInt32,System.UInt32,System.UInt32,System.UInt32,System.Collections.Generic.IDictionary`2<Renci.SshNet.Common.TerminalModes,System.UInt32>)
CreateShell(System.IO.Stream,System.IO.Stream,System.IO.Stream)
CreateShell(System.Text.Encoding,System.String,System.IO.Stream,System.IO.Stream,System.String,System.UInt32,System.UInt32,System.UInt32,System.UInt32,System.Collections.Generic.IDictionary`2<Renci.SshNet.Common.TerminalModes,System.UInt32>,System.Int32)
CreateShell(System.Text.Encoding,System.String,System.IO.Stream,System.IO.Stream,System.String,System.UInt32,System.UInt32,System.UInt32,System.UInt32,System.Collections.Generic.IDictionary`2<Renci.SshNet.Common.TerminalModes,System.UInt32>)
CreateShell(System.Text.Encoding,System.String,System.IO.Stream,System.IO.Stream)
CreateShellStream(System.String,System.UInt32,System.UInt32,System.UInt32,System.UInt32,System.Int32)
CreateShellStream(System.String,System.UInt32,System.UInt32,System.UInt32,System.UInt32,System.Int32,System.Collections.Generic.IDictionary`2<Renci.SshNet.Common.TerminalModes,System.UInt32>)
OnDisconnected()
Dispose(System.Boolean)
EnsureSessionIsOpen()