sshRemoteAgentHostService.ts ×8

Frontier kind: Joint frontier

unlabeled · c_c813517601ff

1 test · 10887 LOC · 48 files · introduces 1 test · 88 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges88 lines · 1 files
Tests
1 test

Contains — complete concept membership

All code (extent)
1640 ranges10887 lines · 48 files · Browse complete extent
All tests (intent)
1 testBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

1 test introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 88 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/sshRemoteAgentHostService.ts 88 introduced LOC · 8 ranges

Open complete file

1034
1035 protected async _connectSSH(
1036 > config: ISSHAgentHostConfig, sshRemoteAgentHostService.ts
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(
1073 liveKbiRequests.add(requestId);
1074 }
1075 > : undefined; sshRemoteAgentHostService.ts
1076 > // Cast: the ssh2 @types don't model `false` (give-up) for the
1077 > // callback nor `null` for the first invocation's `methodsLeft`,
1078 > // even though the runtime supports both per the ssh2 docs.
1079 > connectConfig.authHandler = makeAuthHandler(attempts, this._logService, kbiHandler, keyPassphraseHandler) as unknown as ConnectConfig['authHandler'];
1080 >
1081 > const cancelLiveKbiRequests = () => {
1082 > for (const requestId of liveKbiRequests) {
1083 > // Pull the pending finish callback (if any) and invoke it with
1084 > // empty responses so ssh2 stops waiting on this attempt — without
1085 > // this, ssh2 hangs until `readyTimeout` elapses when a connect
1086 > // attempt is aborted mid-prompt. The renderer also gets notified
1087 > // so it can dismiss any open quick-input UI.
1088 > const pending = this._pendingKbiRequests.get(requestId);
1089 > this._pendingKbiRequests.delete(requestId);
1090 > this._onDidCancelKeyboardInteractive.fire(requestId);
1091 > pending?.finish([]);
1092 > }
1093 > liveKbiRequests.clear();
1094 > };
1095 >
1096 > if (config.agentForward) {
1097 const agentSock = this._getAgentSocket(config);
1098 if (agentSock) {
1107 }
1108 }
1110 > const client = await this._createSSHClient();
1111 > return new Promise<SSHClient>((resolve, reject) => {
1112 > let settled = false;
1113 >
1114 > const resolveConnect = () => {
1115 if (settled) {
1116 return;
1121 resolve(client);
1122 };
1124 > const rejectConnect = (err: Error, endClient: boolean) => {
1125 > if (settled) {
1126 > return;
1127 > }
1128 > settled = true;
1129 > cancelLiveKbiRequests();
1130 > if (endClient) {
1131 > client.end();
1132 > }
1133 > reject(err);
1134 > };
1135 >
1136 > cancelConnectFromKbi = () => {
1137 > this._logService.info(`${LOG_PREFIX} SSH keyboard-interactive prompt cancelled by user for ${displayHost}`);
1138 > rejectConnect(new CancellationError(), true);
1139 > };
1140 >
1141 > client.on('ready', () => {
1142 resolveConnect();
1144 >
1145 > client.on('error', (err: Error) => {
1146 > this._logService.error(`${LOG_PREFIX} SSH connection error: ${err.message}`);
1147 > rejectConnect(err, false);
1148 > });
1149 >
1150 > client.connect(connectConfig);
1151 > });
1152 > }
1153
1154 protected async _createSSHClient(): Promise<SSHClient> {
1299 const finishOnce = (responses: readonly string[]) => {
1300 if (settled) {
1302 > }
1303 settled = true;
1304 this._pendingKbiRequests.delete(requestId);
1326 }
1327 if (responses === undefined) {
1328 > pending.cancelConnect(); sshRemoteAgentHostService.ts
1329 > pending.finish([]);
1330 > return;
1331 > }
1332 pending.finish(responses);
1333 }