< 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

MethodBranch coverage Cyclomatic complexity Line coverage
get_ForwardedPorts()100%1100%
.ctor(...)100%1100%
.ctor(...)100%1100%
.ctor(...)100%1100%
.ctor(...)100%10%
.ctor(...)100%10%
.ctor(...)100%1100%
.ctor(...)100%1100%
OnDisconnecting()100%2100%
AddForwardedPort(...)50%275%
RemoveForwardedPort(...)50%275%
AttachForwardedPort(...)50%466.66%
DetachForwardedPort(...)100%1100%
CreateCommand(...)100%1100%
CreateCommand(...)100%1100%
RunCommand(...)100%1100%
CreateShell(...)100%1100%
CreateShell(...)100%166.66%
CreateShell(...)100%1100%
CreateShell(...)100%190%
CreateShell(...)100%166.66%
CreateShell(...)100%166.66%
CreateShellStream(...)100%1100%
CreateShellStream(...)100%1100%
OnDisconnected()100%2100%
Dispose(...)100%6100%
EnsureSessionIsOpen()100%2100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Diagnostics.CodeAnalysis;
 4using System.IO;
 5using System.Net;
 6using System.Text;
 7
 8using Renci.SshNet.Common;
 9
 10namespace 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
 638            {
 639                return _forwardedPorts.AsReadOnly();
 640            }
 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)
 23155            : this(connectionInfo, ownsConnectionInfo: false)
 23156        {
 23157        }
 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
 9772            : this(new PasswordConnectionInfo(host, port, username, password), ownsConnectionInfo: true)
 73#pragma warning restore CA2000 // Dispose objects before losing scope
 9774        {
 9775        }
 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)
 3989            : this(host, ConnectionInfo.DefaultPort, username, password)
 3990        {
 3991        }
 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)
 0109            : this(new PrivateKeyConnectionInfo(host, port, username, keyFiles), ownsConnectionInfo: true)
 0110        {
 0111        }
 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)
 0126            : this(host, ConnectionInfo.DefaultPort, username, keyFiles)
 0127        {
 0128        }
 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)
 328141            : this(connectionInfo, ownsConnectionInfo, new ServiceFactory())
 328142        {
 328143        }
 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)
 412158            : base(connectionInfo, ownsConnectionInfo, serviceFactory)
 412159        {
 412160            _forwardedPorts = new List<ForwardedPort>();
 412161        }
 162
 163        /// <summary>
 164        /// Called when client is disconnecting from the server.
 165        /// </summary>
 166        protected override void OnDisconnecting()
 500167        {
 500168            base.OnDisconnecting();
 169
 1564170            foreach (var port in _forwardedPorts)
 32171            {
 32172                port.Stop();
 32173            }
 500174        }
 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)
 40188        {
 40189            if (port is null)
 0190            {
 0191                throw new ArgumentNullException(nameof(port));
 192            }
 193
 40194            EnsureSessionIsOpen();
 195
 36196            AttachForwardedPort(port);
 36197            _forwardedPorts.Add(port);
 36198        }
 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)
 4206        {
 4207            if (port is null)
 0208            {
 0209                throw new ArgumentNullException(nameof(port));
 210            }
 211
 212            // Stop port forwarding before removing it
 4213            port.Stop();
 214
 4215            DetachForwardedPort(port);
 4216            _ = _forwardedPorts.Remove(port);
 4217        }
 218
 219        private void AttachForwardedPort(ForwardedPort port)
 36220        {
 36221            if (port.Session != null && port.Session != Session)
 0222            {
 0223                throw new InvalidOperationException("Forwarded port is already added to a different client.");
 224            }
 225
 36226            port.Session = Session;
 36227        }
 228
 229        private static void DetachForwardedPort(ForwardedPort port)
 36230        {
 36231            port.Session = null;
 36232        }
 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)
 724241        {
 724242            return CreateCommand(commandText, ConnectionInfo.Encoding);
 715243        }
 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)
 727255        {
 727256            EnsureSessionIsOpen();
 257
 715258            ConnectionInfo.Encoding = encoding;
 715259            return new SshCommand(Session, commandText, encoding);
 715260        }
 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)
 163278        {
 163279            var cmd = CreateCommand(commandText);
 160280            _ = cmd.Execute();
 160281            return cmd;
 160282        }
 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, 
 19302        {
 19303            EnsureSessionIsOpen();
 304
 1305            return new Shell(Session, input, output, extendedOutput, terminalName, columns, rows, width, height, termina
 1306        }
 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, 
 3325        {
 3326            return CreateShell(input, output, extendedOutput, terminalName, columns, rows, width, height, terminalModes,
 0327        }
 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)
 4340        {
 4341            return CreateShell(input, output, extendedOutput, string.Empty, 0, 0, 0, 0, terminalModes: null, 1024);
 1342        }
 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
 9363        {
 364            /*
 365             * TODO Issue #1224: let shell dispose of input stream when we own the stream!
 366             */
 367
 9368            _inputStream = new MemoryStream();
 369
 9370            using (var writer = new StreamWriter(_inputStream, encoding, bufferSize: 1024, leaveOpen: true))
 9371            {
 9372                writer.Write(input);
 9373                writer.Flush();
 9374            }
 375
 9376            _ = _inputStream.Seek(0, SeekOrigin.Begin);
 377
 9378            return CreateShell(_inputStream, output, extendedOutput, terminalName, columns, rows, width, height, termina
 0379        }
 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
 3399        {
 3400            return CreateShell(encoding, input, output, extendedOutput, terminalName, columns, rows, width, height, term
 0401        }
 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)
 3415        {
 3416            return CreateShell(encoding, input, output, extendedOutput, string.Empty, 0, 0, 0, 0, terminalModes: null, 1
 0417        }
 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 
 14443        {
 14444            return CreateShellStream(terminalName, columns, rows, width, height, bufferSize, terminalModeValues: null);
 11445        }
 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 
 24472        {
 24473            EnsureSessionIsOpen();
 474
 18475            return ServiceFactory.CreateShellStream(Session, terminalName, columns, rows, width, height, terminalModeVal
 18476        }
 477
 478        /// <summary>
 479        /// Stops forwarded ports.
 480        /// </summary>
 481        protected override void OnDisconnected()
 500482        {
 500483            base.OnDisconnected();
 484
 1064485            for (var i = _forwardedPorts.Count - 1; i >= 0; i--)
 32486            {
 32487                var port = _forwardedPorts[i];
 32488                DetachForwardedPort(port);
 32489                _forwardedPorts.RemoveAt(i);
 32490            }
 500491        }
 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)
 427498        {
 427499            base.Dispose(disposing);
 500
 427501            if (_isDisposed)
 15502            {
 15503                return;
 504            }
 505
 412506            if (disposing)
 388507            {
 388508                if (_inputStream != null)
 9509                {
 9510                    _inputStream.Dispose();
 9511                    _inputStream = null;
 9512                }
 513
 388514                _isDisposed = true;
 388515            }
 427516        }
 517
 518        private void EnsureSessionIsOpen()
 810519        {
 810520            if (Session is null)
 40521            {
 40522                throw new SshConnectionException("Client not connected.");
 523            }
 770524        }
 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()