Provides client connection to SSH server.
public class SshClient : BaseClient, ISshClient, IBaseClient, IDisposable
Inheritance
Initializes a new instance of the Renci.SshNet.SshClient class.
public SshClient(ConnectionInfo connectionInfo)
Parameters
connectionInfo
ConnectionInfo
The connection info.
connectionInfo
is null.
Initializes a new instance of the Renci.SshNet.SshClient class.
public SshClient(string host, int port, string username, string password)
Parameters
host
string
Connection host.
port
int
Connection port.
username
string
Authentication username.
password
string
Authentication password.
password
is null.
host
is invalid, or username
is null or contains only whitespace characters.
port
is not within System.Net.IPEndPoint.MinPort and System.Net.IPEndPoint.MaxPort.
Initializes a new instance of the Renci.SshNet.SshClient class.
public SshClient(string host, string username, string password)
Parameters
host
string
Connection host.
username
string
Authentication username.
password
string
Authentication password.
password
is null.
host
is invalid, or username
is null or contains only whitespace characters.
Initializes a new instance of the Renci.SshNet.SshClient class.
public SshClient(string host, int port, string username, params IPrivateKeySource[] keyFiles)
Parameters
host
string
Connection host.
port
int
Connection port.
username
string
Authentication username.
keyFiles
IPrivateKeySource[]
Authentication private key file(s) .
keyFiles
is null.
host
is invalid, -or- username
is null or contains only whitespace characters.
port
is not within System.Net.IPEndPoint.MinPort and System.Net.IPEndPoint.MaxPort.
Initializes a new instance of the Renci.SshNet.SshClient class.
public SshClient(string host, string username, params IPrivateKeySource[] keyFiles)
Parameters
host
string
Connection host.
username
string
Authentication username.
keyFiles
IPrivateKeySource[]
Authentication private key file(s) .
keyFiles
is null.
host
is invalid, -or- username
is null or contains only whitespace characters.
Gets the list of forwarded ports.
public IEnumerable<ForwardedPort> ForwardedPorts { get; }
Property Value
Adds the forwarded port.
public void AddForwardedPort(ForwardedPort port)
Parameters
port
ForwardedPort
The port.
Forwarded port is already added to a different client.
port
is null.
Client is not connected.
Creates the command to be executed.
public SshCommand CreateCommand(string commandText)
Parameters
commandText
string
The command text.
Renci.SshNet.SshCommand object.
Client is not connected.
Creates the command to be executed with specified encoding.
public SshCommand CreateCommand(string commandText, Encoding encoding)
Parameters
commandText
string
The command text.
encoding
Encoding
The encoding to use for results.
Renci.SshNet.SshCommand object which uses specified encoding.
This method will change current default encoding.
ExceptionsClient is not connected.
commandText
or encoding
is null.
Creates the shell.
public 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 a representation of a Renci.SshNet.Shell object.
Client is not connected.
Creates the shell.
public 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 a representation of a Renci.SshNet.Shell object.
Client is not connected.
Creates the shell.
public Shell CreateShell(Stream input, Stream output, Stream extendedOutput)
Parameters
input
Stream
The input.
output
Stream
The output.
extendedOutput
Stream
The extended output.
Returns a representation of a Renci.SshNet.Shell object.
Client is not connected.
Creates the shell.
public 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 a representation of a Renci.SshNet.Shell object.
Client is not connected.
Creates the shell.
public 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 a representation of a Renci.SshNet.Shell object.
Client is not connected.
Creates the shell.
public 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 a representation of a Renci.SshNet.Shell object.
Client is not connected.
Creates the shell without allocating a pseudo terminal, similar to the ssh -T
option.
public 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 a representation of a Renci.SshNet.Shell object.
Client is not connected.
Creates the shell stream.
public 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.
The created Renci.SshNet.ShellStream instance.
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.
ExceptionsClient is not connected.
Creates the shell stream.
public 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.
The created Renci.SshNet.ShellStream instance.
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.
ExceptionsClient is not connected.
Creates the shell stream without allocating a pseudo terminal, similar to the ssh -T
option.
public ShellStream CreateShellStreamNoTerminal(int bufferSize = -1)
Parameters
bufferSize
int
The size of the buffer.
The created Renci.SshNet.ShellStream instance.
Client is not connected.
Releases unmanaged and - optionally - managed resources.
protected override void Dispose(bool disposing)
Parameters
disposing
bool
true to release both managed and unmanaged resources; false to release only unmanaged resources.
Stops forwarded ports.
protected override void OnDisconnected()
OnDisconnecting()
Called when client is disconnecting from the server.
protected override void OnDisconnecting()
RemoveForwardedPort(ForwardedPort)
Stops and removes the forwarded port from the list.
public void RemoveForwardedPort(ForwardedPort port)
Parameters
port
ForwardedPort
Forwarded port.
port
is null.
Creates and executes the command.
public SshCommand RunCommand(string commandText)
Parameters
commandText
string
The command text.
Returns an instance of Renci.SshNet.SshCommand with execution results.
This method internally uses asynchronous calls.
ExceptionsCommandText property is empty.
Invalid Operation - An existing channel was used to execute this command.
Asynchronous operation is already in progress.
Client is not connected.
commandText
is null.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4