<PackageReference Include="SSH.NET" Version="2024.2.0" />

SshCommand

public class SshCommand : IDisposable
Represents an SSH command that can be executed.
public string CommandText { get; }

Gets the command text.

public TimeSpan CommandTimeout { get; set; }

Gets or sets the command timeout.

public string Error { get; }

Gets the standard error of the command by reading ExtendedOutputStream, when extended data has been sent which has been marked as stderr.

public string ExitSignal { get; }

Gets the name of the signal due to which the command terminated violently, if applicable, otherwise null.

public int? ExitStatus { get; }

Gets the number representing the exit status of the command, if applicable, otherwise null.

public Stream ExtendedOutputStream { get; }

Gets the extended output stream.

public Stream OutputStream { get; }

Gets the output stream.

public string Result { get; }

Gets the standard output of the command by reading OutputStream.

Begins an asynchronous command execution.

Begins an asynchronous command execution.

public IAsyncResult BeginExecute(AsyncCallback callback, object state)

Begins an asynchronous command execution.

public IAsyncResult BeginExecute(string commandText, AsyncCallback callback, object state)

Begins an asynchronous command execution.

public void CancelAsync(bool forceKill = false, int millisecondsTimeout = 500)

Cancels a running command by sending a signal to the remote process.

Creates and returns the input stream for the command.

public void Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

protected virtual void Dispose(bool disposing)

Releases unmanaged and - optionally - managed resources.

public string EndExecute(IAsyncResult asyncResult)

Waits for the pending asynchronous command execution to complete.

public string Execute()

Executes the command specified by CommandText.

public string Execute(string commandText)

Executes the specified command.

public Task ExecuteAsync(CancellationToken cancellationToken = default)

Executes the command asynchronously.