SSH

public class SSH

SSH Connection This class automatically manages a connection pool to run multiple commands at the same time

  • Initialize the SSH Connection class

    Note

    At this moment no SSH connection is active

    Declaration

    Swift

    public init(options: SSHOption)

    Parameters

    options

    Options required for a SSH connection

  • disconnect() Asynchronous

    Disconnect the underlying SSH pool

    Declaration

    Swift

    public func disconnect() async
  • exec(command:) Asynchronous

    Execute a command in the SSH connection pool

    Declaration

    Swift

    public func exec(command: String) async throws -> SSHExecResult

    Parameters

    command

    Command to execute on the remote host

    Return Value

    SSHExecResult containing the result of the execution

  • Execute a command in the SSH connection pool

    Declaration

    Swift

    public func exec(command: String, delegate: SSHExecDelegate?, notCancelable: Bool = false) async throws -> SSHExecResult

    Parameters

    command

    Command to execute on the remote host

    delegate

    Events like SSHExecDelegate.onStdout or SSHExecDelegate.onStderr get called on this object. This can provide realtime features

    notCancelable

    If this is true, the required command wrapper which is needed for cancel(id:) doesn’t get add. This parameter is optional and normally you should leave it alone

    Return Value

    SSHExecResult containing the result of the execution

  • cancel(id:) Asynchronous

    Cancel a command on the remote machine

    Warning

    If the ssh pool is satisfied, this function doesn’t return until a connection gets freed up

    Declaration

    Swift

    public func cancel(id: String) async throws

    Parameters

    id

    Id of the command which gets passed in the SSHExecDelegate.cancelFunction method of the SSHExecDelegate in exec(command:delegate:notCancelable:)