AuthHandler

interface AuthHandler(source)

Callback-driven authentication handler.

The library drives the authentication flow per RFC 4252, calling back into this handler for materials. The flow is: none → publickey probe → sign → keyboard-interactive → password

Functions

Link copied to clipboard
open suspend fun onAuthMethodsAvailable(methods: Set<String>)

Called when the server reports which authentication methods are available. Override to observe or log.

Link copied to clipboard
open suspend fun onBanner(message: String)

Called when the server sends an authentication banner (SSH_MSG_USERAUTH_BANNER). This is often used for out-of-band authentication instructions (e.g., a URL to visit).

Link copied to clipboard
abstract suspend fun onKeyboardInteractivePrompt(name: String, instruction: String, prompts: List<KeyboardInteractiveCallback.Prompt>): List<String>?

Called when the server sends keyboard-interactive prompts. Return responses (one per prompt), or null to skip keyboard-interactive.

Link copied to clipboard
abstract suspend fun onPasswordNeeded(): String?

Return the password, or null to skip password auth.

Link copied to clipboard
abstract suspend fun onPublicKeysNeeded(): List<AuthPublicKey>

Return public keys to probe. Empty list skips public key auth.

Link copied to clipboard
abstract suspend fun onSignatureRequest(key: AuthPublicKey, dataToSign: ByteArray): ByteArray?

Called only for keys the server accepted (PK_OK). Return the signature over dataToSign, or null to skip this key.