SshSession

Represents an SSH session channel (RFC 4254 section 6).

Session channels are used for interactive shells, command execution, and subsystem invocation (like SFTP).

Inheritors

Properties

Link copied to clipboard
abstract val exitInfo: Deferred<SessionExit?>

Completes with how the remote process terminated once the server reports it (RFC 4254 section 6.10), or with null when the channel closes without an exit-status/exit-signal notification. Servers are not required to send one, so null means unknown, not failure.

Link copied to clipboard
abstract val isOpen: Boolean
Link copied to clipboard
abstract val localChannelNumber: Int
Link copied to clipboard
abstract val remoteChannelNumber: Int
Link copied to clipboard
abstract val stderr: ReceiveChannel<ByteArray>
Link copied to clipboard
abstract val stdout: ReceiveChannel<ByteArray>

Functions

Link copied to clipboard
abstract override fun close()
Link copied to clipboard
abstract suspend fun read(): ByteArray?
Link copied to clipboard
abstract suspend fun readExtended(): Pair<Int, ByteArray>?

Read non-stderr extended data. RFC 4254 data type 1 is exposed exclusively through stderr so the same remote bytes are not buffered twice.

Link copied to clipboard
abstract suspend fun requestExec(command: String): Boolean

Request execution of a command on this session channel (RFC 4254 section 6.5).

Link copied to clipboard
abstract suspend fun requestPty(terminalType: String = "xterm", widthChars: Int = 80, heightRows: Int = 24, widthPixels: Int = 0, heightPixels: Int = 0, terminalModes: ByteArray = byteArrayOf(0)): Boolean
Link copied to clipboard
abstract suspend fun requestShell(): Boolean
Link copied to clipboard
abstract suspend fun requestSubsystem(name: String): Boolean

Request a subsystem on this session channel (RFC 4254 section 6.5).

Link copied to clipboard
abstract suspend fun resizeTerminal(widthChars: Int, heightRows: Int, widthPixels: Int, heightPixels: Int): Boolean
Link copied to clipboard
abstract suspend fun sendEof()
Link copied to clipboard
abstract suspend fun write(data: ByteArray)

Write data, suspending for channel window credit and transport backpressure.