C# Class Renci.SshNet.SshClient

Provides client connection to SSH server.
Inheritance: BaseClient
Exibir arquivo Open project: sshnet/SSH.NET Class Usage Examples

Public Methods

Method Description
AddForwardedPort ( ForwardedPort port ) : void

Adds the forwarded port.

CreateCommand ( string commandText ) : SshCommand

Creates the command to be executed.

CreateCommand ( string commandText, Encoding encoding ) : SshCommand

Creates the command to be executed with specified encoding.

This method will change current default encoding.

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

Creates the shell.

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

Creates the shell.

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

Creates the shell.

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

Creates the shell.

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

Creates the shell.

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

Creates the shell.

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

Creates the shell stream.

The TERM environment variable contains an identifier for the text window's capabilities. You can get a detailed list of these cababilities 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.

CreateShellStream ( string terminalName, uint columns, uint rows, uint width, uint height, int bufferSize, uint>.IDictionary terminalModeValues ) : ShellStream

Creates the shell stream.

The TERM environment variable contains an identifier for the text window's capabilities. You can get a detailed list of these cababilities 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.

RemoveForwardedPort ( ForwardedPort port ) : void

Stops and removes the forwarded port from the list.

RunCommand ( string commandText ) : SshCommand

Creates and executes the command.

This method internally uses asynchronous calls.

SshClient ( ConnectionInfo connectionInfo ) : System

Initializes a new instance of the SshClient class.

SshClient ( string host, string username ) : System

Initializes a new instance of the SshClient class.

SshClient ( string host, string username, string password ) : System

Initializes a new instance of the SshClient class.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Releases unmanaged and - optionally - managed resources

OnDisconnected ( ) : void

Stops forwarded ports.

OnDisconnecting ( ) : void

Called when client is disconnecting from the server.

Private Methods

Method Description
AttachForwardedPort ( ForwardedPort port ) : void
DetachForwardedPort ( ForwardedPort port ) : void
EnsureSessionIsOpen ( ) : void
SshClient ( ConnectionInfo connectionInfo, bool ownsConnectionInfo ) : System

Initializes a new instance of the SshClient class.

If ownsConnectionInfo is true, then the connection info will be disposed when this instance is disposed.

SshClient ( ConnectionInfo connectionInfo, bool ownsConnectionInfo, IServiceFactory serviceFactory ) : System

Initializes a new instance of the SshClient class.

If ownsConnectionInfo is true, then the connection info will be disposed when this instance is disposed.

SshClient ( string host, int port, string username ) : System
SshClient ( string host, int port, string username, string password ) : System

Method Details

AddForwardedPort() public method

Adds the forwarded port.
Forwarded port is already added to a different client. is null. Client is not connected.
public AddForwardedPort ( ForwardedPort port ) : void
port ForwardedPort The port.
return void

CreateCommand() public method

Creates the command to be executed.
Client is not connected.
public CreateCommand ( string commandText ) : SshCommand
commandText string The command text.
return SshCommand

CreateCommand() public method

Creates the command to be executed with specified encoding.
This method will change current default encoding.
Client is not connected. or is null.
public CreateCommand ( string commandText, Encoding encoding ) : SshCommand
commandText string The command text.
encoding System.Text.Encoding The encoding to use for results.
return SshCommand

CreateShell() public method

Creates the shell.
Client is not connected.
public CreateShell ( Encoding encoding, string input, Stream output, Stream extendedOutput ) : Shell
encoding System.Text.Encoding The encoding.
input string The input.
output Stream The output.
extendedOutput Stream The extended output.
return Shell

CreateShell() public method

Creates the shell.
Client is not connected.
public CreateShell ( Encoding encoding, string input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, uint>.IDictionary terminalModes ) : Shell
encoding System.Text.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 uint>.IDictionary The terminal modes.
return Shell

CreateShell() public method

Creates the shell.
Client is not connected.
public CreateShell ( Encoding encoding, string input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, uint>.IDictionary terminalModes, int bufferSize ) : Shell
encoding System.Text.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 uint>.IDictionary The terminal mode.
bufferSize int Size of the internal read buffer.
return Shell

CreateShell() public method

Creates the shell.
Client is not connected.
public CreateShell ( Stream input, Stream output, Stream extendedOutput ) : Shell
input Stream The input.
output Stream The output.
extendedOutput Stream The extended output.
return Shell

CreateShell() public method

Creates the shell.
Client is not connected.
public CreateShell ( Stream input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, uint>.IDictionary terminalModes ) : Shell
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 uint>.IDictionary The terminal mode.
return Shell

CreateShell() public method

Creates the shell.
Client is not connected.
public CreateShell ( Stream input, Stream output, Stream extendedOutput, string terminalName, uint columns, uint rows, uint width, uint height, uint>.IDictionary terminalModes, int bufferSize ) : Shell
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 uint>.IDictionary The terminal mode.
bufferSize int Size of the internal read buffer.
return Shell

CreateShellStream() public method

Creates the shell stream.

The TERM environment variable contains an identifier for the text window's capabilities. You can get a detailed list of these cababilities 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.

Client is not connected.
public CreateShellStream ( string terminalName, uint columns, uint rows, uint width, uint height, int bufferSize ) : ShellStream
terminalName string The TERM environment variable.
columns uint The terminal width in columns.
rows uint The terminal width in rows.
width uint The terminal height in pixels.
height uint The terminal height in pixels.
bufferSize int Size of the buffer.
return ShellStream

CreateShellStream() public method

Creates the shell stream.

The TERM environment variable contains an identifier for the text window's capabilities. You can get a detailed list of these cababilities 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.

Client is not connected.
public CreateShellStream ( string terminalName, uint columns, uint rows, uint width, uint height, int bufferSize, uint>.IDictionary terminalModeValues ) : ShellStream
terminalName string The TERM environment variable.
columns uint The terminal width in columns.
rows uint The terminal width in rows.
width uint The terminal height in pixels.
height uint The terminal height in pixels.
bufferSize int Size of the buffer.
terminalModeValues uint>.IDictionary The terminal mode values.
return ShellStream

Dispose() protected method

Releases unmanaged and - optionally - managed resources
protected Dispose ( bool disposing ) : void
disposing bool true to release both managed and unmanaged resources; false to release only unmanaged resources.
return void

OnDisconnected() protected method

Stops forwarded ports.
protected OnDisconnected ( ) : void
return void

OnDisconnecting() protected method

Called when client is disconnecting from the server.
protected OnDisconnecting ( ) : void
return void

RemoveForwardedPort() public method

Stops and removes the forwarded port from the list.
is null.
public RemoveForwardedPort ( ForwardedPort port ) : void
port ForwardedPort Forwarded port.
return void

RunCommand() public method

Creates and executes the command.
This method internally uses asynchronous calls.
CommandText property is empty. Invalid Operation - An existing channel was used to execute this command. Asynchronous operation is already in progress. Client is not connected. is null.
public RunCommand ( string commandText ) : SshCommand
commandText string The command text.
return SshCommand

SshClient() public method

Initializes a new instance of the SshClient class.
is null.
public SshClient ( ConnectionInfo connectionInfo ) : System
connectionInfo ConnectionInfo The connection info.
return System

SshClient() public method

Initializes a new instance of the SshClient class.
is null. is invalid, -or- is null or contains only whitespace characters.
public SshClient ( string host, string username ) : System
host string Connection host.
username string Authentication username.
return System

SshClient() public method

Initializes a new instance of the SshClient class.
is null. is invalid, or is null or contains only whitespace characters.
public SshClient ( string host, string username, string password ) : System
host string Connection host.
username string Authentication username.
password string Authentication password.
return System