Table of Contents

Interface ISshClient

Namespace
Renci.SshNet
Assembly
Renci.SshNet.dll

Provides client connection to SSH server.

public interface ISshClient : IBaseClient, IDisposable

Implements

Properties

ForwardedPorts

Gets the list of forwarded ports.

IEnumerable<ForwardedPort> ForwardedPorts { get; }

Property Value

IEnumerable<ForwardedPort>

Methods

AddForwardedPort(ForwardedPort)

Adds the forwarded port.

void AddForwardedPort(ForwardedPort port)

Parameters

port ForwardedPort

The port.

Exceptions

InvalidOperationException

Forwarded port is already added to a different client.

ArgumentNullException

port is null.

SshConnectionException

Client is not connected.

CreateCommand(string)

Creates the command to be executed.

SshCommand CreateCommand(string commandText)

Parameters

commandText string

The command text.

Returns

SshCommand

Renci.SshNet.SshCommand object.

Exceptions

SshConnectionException

Client is not connected.

CreateCommand(string, Encoding)

Creates the command to be executed with specified encoding.

SshCommand CreateCommand(string commandText, Encoding encoding)

Parameters

commandText string

The command text.

encoding Encoding

The encoding to use for results.

Returns

SshCommand

Renci.SshNet.SshCommand object which uses specified encoding.

Remarks

This method will change current default encoding.

Exceptions

SshConnectionException

Client is not connected.

ArgumentNullException

commandText or encoding is null.

CreateShell(Stream, Stream, Stream, string, uint, uint, uint, uint, IDictionary<TerminalModes, uint>?, int)

Creates the shell.

Shell CreateShell(Stream input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, IDictionary<TerminalModes, uint>? terminalModes, int bufferSize)

Parameters

input Stream

The input.

output Stream

The output.

extendedOutput Stream

The extended output.

terminalName string

Name of the terminal.

columns uint

The columns.

rows uint

The rows.

width uint

The width.

height uint

The height.

terminalModes IDictionary<TerminalModes, uint>?

The terminal mode.

bufferSize int

Size of the internal read buffer.

Returns

Shell

Returns a representation of a Renci.SshNet.Shell object.

Exceptions

SshConnectionException

Client is not connected.

CreateShell(Stream, Stream, Stream, string, uint, uint, uint, uint, IDictionary<TerminalModes, uint>)

Creates the shell.

Shell CreateShell(Stream input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, IDictionary<TerminalModes, uint> terminalModes)

Parameters

input Stream

The input.

output Stream

The output.

extendedOutput Stream

The extended output.

terminalName string

Name of the terminal.

columns uint

The columns.

rows uint

The rows.

width uint

The width.

height uint

The height.

terminalModes IDictionary<TerminalModes, uint>

The terminal mode.

Returns

Shell

Returns a representation of a Renci.SshNet.Shell object.

Exceptions

SshConnectionException

Client is not connected.

CreateShell(Stream, Stream, Stream)

Creates the shell.

Shell CreateShell(Stream input, Stream output, Stream extendedOutput)

Parameters

input Stream

The input.

output Stream

The output.

extendedOutput Stream

The extended output.

Returns

Shell

Returns a representation of a Renci.SshNet.Shell object.

Exceptions

SshConnectionException

Client is not connected.

CreateShell(Encoding, string, Stream, Stream, string, uint, uint, uint, uint, IDictionary<TerminalModes, uint>?, int)

Creates the shell.

Shell CreateShell(Encoding encoding, string input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, IDictionary<TerminalModes, uint>? terminalModes, int bufferSize)

Parameters

encoding Encoding

The encoding to use to send the input.

input string

The input.

output Stream

The output.

extendedOutput Stream

The extended output.

terminalName string

Name of the terminal.

columns uint

The columns.

rows uint

The rows.

width uint

The width.

height uint

The height.

terminalModes IDictionary<TerminalModes, uint>?

The terminal mode.

bufferSize int

Size of the internal read buffer.

Returns

Shell

Returns a representation of a Renci.SshNet.Shell object.

Exceptions

SshConnectionException

Client is not connected.

CreateShell(Encoding, string, Stream, Stream, string, uint, uint, uint, uint, IDictionary<TerminalModes, uint>)

Creates the shell.

Shell CreateShell(Encoding encoding, string input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, IDictionary<TerminalModes, uint> terminalModes)

Parameters

encoding Encoding

The encoding.

input string

The input.

output Stream

The output.

extendedOutput Stream

The extended output.

terminalName string

Name of the terminal.

columns uint

The columns.

rows uint

The rows.

width uint

The width.

height uint

The height.

terminalModes IDictionary<TerminalModes, uint>

The terminal modes.

Returns

Shell

Returns a representation of a Renci.SshNet.Shell object.

Exceptions

SshConnectionException

Client is not connected.

CreateShell(Encoding, string, Stream, Stream)

Creates the shell.

Shell CreateShell(Encoding encoding, string input, Stream output, Stream extendedOutput)

Parameters

encoding Encoding

The encoding.

input string

The input.

output Stream

The output.

extendedOutput Stream

The extended output.

Returns

Shell

Returns a representation of a Renci.SshNet.Shell object.

Exceptions

SshConnectionException

Client is not connected.

CreateShellNoTerminal(Stream, Stream, Stream, int)

Creates the shell without allocating a pseudo terminal, similar to the ssh -T option.

Shell CreateShellNoTerminal(Stream input, Stream output, Stream extendedOutput, int bufferSize = -1)

Parameters

input Stream

The input.

output Stream

The output.

extendedOutput Stream

The extended output.

bufferSize int

Size of the internal read buffer.

Returns

Shell

Returns a representation of a Renci.SshNet.Shell object.

Exceptions

SshConnectionException

Client is not connected.

CreateShellStream(string, uint, uint, uint, uint, int)

Creates the shell stream.

ShellStream CreateShellStream(string terminalName, uint columns, uint rows, uint width, uint height, int bufferSize)

Parameters

terminalName string

The TERM environment variable.

columns uint

The terminal width in columns.

rows uint

The terminal width in rows.

width uint

The terminal width in pixels.

height uint

The terminal height in pixels.

bufferSize int

The size of the buffer.

Returns

ShellStream

The created Renci.SshNet.ShellStream instance.

Remarks

The TERM environment variable contains an identifier for the text window's capabilities. You can get a detailed list of these capabilities by using the ‘infocmp’ command.

The column/row dimensions override the pixel dimensions(when nonzero). Pixel dimensions refer to the drawable area of the window.

Exceptions

SshConnectionException

Client is not connected.

CreateShellStream(string, uint, uint, uint, uint, int, IDictionary<TerminalModes, uint>?)

Creates the shell stream.

ShellStream CreateShellStream(string terminalName, uint columns, uint rows, uint width, uint height, int bufferSize, IDictionary<TerminalModes, uint>? terminalModeValues)

Parameters

terminalName string

The TERM environment variable.

columns uint

The terminal width in columns.

rows uint

The terminal width in rows.

width uint

The terminal width in pixels.

height uint

The terminal height in pixels.

bufferSize int

The size of the buffer.

terminalModeValues IDictionary<TerminalModes, uint>?

The terminal mode values.

Returns

ShellStream

The created Renci.SshNet.ShellStream instance.

Remarks

The TERM environment variable contains an identifier for the text window's capabilities. You can get a detailed list of these capabilities by using the ‘infocmp’ command.

The column/row dimensions override the pixel dimensions(when non-zero). Pixel dimensions refer to the drawable area of the window.

Exceptions

SshConnectionException

Client is not connected.

CreateShellStreamNoTerminal(int)

Creates the shell stream without allocating a pseudo terminal, similar to the ssh -T option.

ShellStream CreateShellStreamNoTerminal(int bufferSize = -1)

Parameters

bufferSize int

The size of the buffer.

Returns

ShellStream

The created Renci.SshNet.ShellStream instance.

Exceptions

SshConnectionException

Client is not connected.

RemoveForwardedPort(ForwardedPort)

Stops and removes the forwarded port from the list.

void RemoveForwardedPort(ForwardedPort port)

Parameters

port ForwardedPort

Forwarded port.

Exceptions

ArgumentNullException

port is null.

RunCommand(string)

Creates and executes the command.

SshCommand RunCommand(string commandText)

Parameters

commandText string

The command text.

Returns

SshCommand

Returns an instance of Renci.SshNet.SshCommand with execution results.

Remarks

This method internally uses asynchronous calls.

Exceptions

ArgumentException

CommandText property is empty.

SshException

Invalid Operation - An existing channel was used to execute this command.

InvalidOperationException

Asynchronous operation is already in progress.

SshConnectionException

Client is not connected.

ArgumentNullException

commandText is null.