SshConnection

class SshConnection(transport: Transport, clientVersion: String = "SSH-2.0-CBSSH_1.0", hostKeyVerifier: HostKeyVerifier, kexAlgorithms: String = KexEntry.defaultString, hostKeyAlgorithms: String = SignatureEntry.defaultString, encryptionAlgorithms: String = CipherEntry.defaultString, macAlgorithms: String = MacEntry.defaultString, compressionAlgorithms: String = CompressionEntry.defaultString, preferPasswordAuth: Boolean = false, rekeyIntervalMs: Long, rekeyBytesLimit: Long, obscureKeystrokeTimingIntervalMs: Long = 20, coroutineDispatcher: CoroutineDispatcher = Dispatchers.IO)(source)

SSH connection handler that manages the protocol flow.

This class ties together the state machine, transport layer, and crypto implementations to handle a complete SSH connection lifecycle.

Parameters

transport

Underlying transport (e.g., TCP socket)

clientVersion

Client version string (default: SSH-2.0-CBSSH_1.0)

Constructors

Link copied to clipboard
constructor(transport: Transport, clientVersion: String = "SSH-2.0-CBSSH_1.0", hostKeyVerifier: HostKeyVerifier, kexAlgorithms: String = KexEntry.defaultString, hostKeyAlgorithms: String = SignatureEntry.defaultString, encryptionAlgorithms: String = CipherEntry.defaultString, macAlgorithms: String = MacEntry.defaultString, compressionAlgorithms: String = CompressionEntry.defaultString, preferPasswordAuth: Boolean = false, rekeyIntervalMs: Long, rekeyBytesLimit: Long, obscureKeystrokeTimingIntervalMs: Long = 20, coroutineDispatcher: CoroutineDispatcher = Dispatchers.IO)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val disconnectedFlow: SharedFlow<Throwable?>

Functions

Link copied to clipboard

Authenticate using keyboard-interactive (RFC 4256).

Link copied to clipboard
suspend fun authenticatePassword(username: String, password: String): AuthResult

Authenticate using password.

Link copied to clipboard
suspend fun close()
Link copied to clipboard
suspend fun connect(): ConnectResult

Initiate SSH connection. Performs SSH version exchange, key exchange, and service negotiation. Returns ConnectResult.Success when the transport is ready for authentication calls.

Link copied to clipboard

Enable SSH agent forwarding with the provided agent.

Link copied to clipboard
suspend fun openSessionChannel(initialWindowSize: Int = sessionWindowSize, maxPacketSize: Int = 32 * 1024): SessionChannel?

Open a session channel (RFC 4254 section 6.1).