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 activeDeclaration
Swift
public init(options: SSHOption)
Parameters
options
Options required for a SSH connection
-
disconnect()
AsynchronousDisconnect 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 -
exec(command:
Asynchronousdelegate: notCancelable: ) 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
orSSHExecDelegate.onStderr
get called on this object. This can provide realtime featuresnotCancelable
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 aloneReturn 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 upDeclaration
Swift
public func cancel(id: String) async throws
Parameters
id
Id of the command which gets passed in the
SSHExecDelegate.cancelFunction
method of theSSHExecDelegate
inexec(command:delegate:notCancelable:)