SSH Connection API - TJohn2017/Laputa GitHub Wiki
The SSHConnection class provides the core SSH functionality necessary to establish, authenticate, write to, resize a terminal for, and disconnect from SSH connections. One connection should be created and managed for each desired connection (i.e. one per terminal view, even if they are for the same host). The file is found at: SSHConnection.swift
Connect accepts an object populated with connection data and attempts to establish that connection. It creates the initial connection, authorizes (if necessary), and requests an Xterm pseudo-terminal (Xterm is the robust emulation format used by SwiftTerm).
hostInfo: HostInfo (A populated object containing host and authorization data)
void
- SSHSessionError.authorizationFailed (The connection was established but failed to authorize)
- SSHSessionError.connectFailed (The initial connection failed to be made)
Closes the open shell and disconnects from the host.
None
void
None
Accepts a command with arguments to be executed over the open connection. The result of this command is waited for and returned to the user. Note: this command is incompatible with the pseudo-terminal format used to power the terminals, and thus is currently unused.
command: String (The command to be executed)
String: the result output of the command.
None
Accepts an array slice of data in bytes to be written over the current connection's pseudo-terminal. This is done by converting the provided data to a string and writing that string in its entirety to the ssh connection. If successful nothing is returned, but throws on error.
data: ArraySlice (The data to be written in an array of UInt8's (bytes))
void
NMSSHChannelWriteError (populated with more detailed error objects by NMSSH)
Requests a new terminal size from the host connection in characters wide and high, returning the success state of the request as a boolean value.
- width: UInt (The desired terminal width in characters)
- height: UInt (The desired terminal height in characters)
Bool (True on success and false on failure)
None
Returns true if a session is currently connected or false if it is not.
None
Bool (Whether or not there is an open connection)
None