1034
1035
protected async _connectSSH(
1037
>
connectionKey?: string,
1038
>
): Promise<SSHClient> {
1039
>
const connectConfig: ConnectConfig = {
1040
>
host: config.host,
1041
>
port: config.port ?? 22,
1042
>
username: config.username,
1043
>
readyTimeout: 30_000,
1044
>
keepaliveInterval: 15_000,
1045
>
};
1046
>
1047
>
const attempts = await this._buildAuthAttempts(config);
1048
>
this._logService.info(`${LOG_PREFIX} Built ${attempts.length} auth attempt(s): ${attempts.map(a => describeAuthAttempt(a)).join(', ')}`);
1049
>
const displayHost = config.sshConfigHost ?? `${config.username}@${config.host}`;
1050
>
// Track requestIds we created during this connect so we can fire
1051
>
// onDidCancelKeyboardInteractive for any still-pending prompts when
1052
>
// the connect attempt fails or completes.
1053
>
const liveKbiRequests = new Set<string>();
1054
>
let cancelConnectFromKbi: (() => void) | undefined;
1055
>
const kbiHandler: SSHKeyboardInteractivePromptHandler | undefined = attempts.some(a => a.type === 'keyboard-interactive')
1056
>
? (name, instructions, prompts, finish) => {
1057
>
const requestId = this._handleKeyboardInteractive(connectionKey ?? displayHost, displayHost, config.username, name, instructions, prompts, finish, () => cancelConnectFromKbi?.());
1058
>
liveKbiRequests.add(requestId);
1059
>
}
1060
: undefined;
1061
>
const keyPassphraseHandler: SSHKeyPassphrasePromptHandler | undefined = attempts.some(a => a.type === 'publickey' && a.encrypted)
sshRemoteAgentHostService.ts
1062
? (keyPath, finish) => {
1063
const requestId = this._handleKeyboardInteractive(