feat: keyboard-interactive auth (#349)

This commit is contained in:
lollipopkit
2024-05-07 15:22:31 +08:00
parent 026e414388
commit d0523c1e54
15 changed files with 137 additions and 69 deletions

View File

@@ -56,6 +56,9 @@ Future<SSHClient> genClient(
///
/// Must pass this param when use multi-thread and key login
ServerPrivateInfo? jumpSpi,
/// Handle keyboard-interactive authentication
FutureOr<List<String>?> Function(SSHUserInfoRequest)? onKeyboardInteractive,
}) async {
onStatus?.call(GenSSHClientStatus.socket);
@@ -109,6 +112,9 @@ Future<SSHClient> genClient(
socket,
username: spi.user,
onPasswordRequest: () => spi.pwd,
onUserInfoRequest: onKeyboardInteractive,
printDebug: debugPrint,
printTrace: debugPrint,
);
}
privateKey ??= getPrivateKey(keyId);
@@ -119,5 +125,8 @@ Future<SSHClient> genClient(
username: spi.user,
// Must use [compute] here, instead of [Computer.shared.start]
identities: await compute(loadIndentity, privateKey),
onUserInfoRequest: onKeyboardInteractive,
printDebug: debugPrint,
printTrace: debugPrint,
);
}