870
871
async reconnect(sshConfigHost: string, name: string, remoteAgentHostCommand?: string, agentForward?: boolean): Promise<ISSHConnectResult> {
873
>
const resolved = await this.resolveSSHConfig(sshConfigHost);
874
>
875
>
// Always use Agent auth — the auth handler will walk through the SSH
876
>
// agent and any default identities. If the user pinned a non-default
877
>
// `IdentityFile` in their ssh config, surface it as the explicit key
878
>
// so it gets tried first.
879
>
let privateKeyPath: string | undefined;
880
>
if (resolved.identityFile.length > 0 && !SSHRemoteAgentHostMainService._isDefaultKeyPath(resolved.identityFile[0])) {
881
privateKeyPath = resolved.identityFile[0];
882
}
883
>
this._logService.info(`${LOG_PREFIX} reconnect: identityFiles=${JSON.stringify(resolved.identityFile)}, explicit key=${privateKeyPath ?? '(none)'}`);
sshRemoteAgentHostService.ts
884
>
885
>
return this.connect({
886
>
host: resolved.hostname,
887
>
port: resolved.port !== 22 ? resolved.port : undefined,
888
>
username: resolved.user ?? sshConfigHost,
889
>
authMethod: SSHAuthMethod.Agent,
890
>
privateKeyPath,
891
>
identityAgent: resolved.identityAgent,
892
>
name,
893
>
sshConfigHost,
894
>
remoteAgentHostCommand,
895
>
agentForward: agentForward && resolved.forwardAgent ? true : undefined,
896
>
}, /* replaceRelay */ true);
897
>
}
898
899
async listSSHConfigHosts(): Promise<string[]> {