Ssh Connection
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)
client Version
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)
Functions
Link copied to clipboard
suspend fun authenticateKeyboardInteractive(username: String, callback: KeyboardInteractiveCallback): AuthResult
Authenticate using keyboard-interactive (RFC 4256).
Link copied to clipboard
Authenticate using password.
Link copied to clipboard
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).