Skip to content

Commit 72a43e1

Browse files
committed
Proper fix ProxyCommand on windows
1 parent 78781fb commit 72a43e1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/authResolver.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,19 @@ export class RemoteSSHResolver implements vscode.RemoteAuthorityResolver, vscode
152152
proxyStream = await proxyConnection.forwardOut('127.0.0.1', 0, destIP, destPort);
153153
}
154154
} else if (sshHostConfig['ProxyCommand']) {
155-
const proxyArgs = (sshHostConfig['ProxyCommand'] as unknown as string[])
156-
.map((arg) => `"${arg.replace('%h', sshHostName).replace('%p', sshPort.toString()).replace('%r', sshUser)}"`);
157-
const proxyCommand = proxyArgs.shift()!;
158-
159-
this.logger.trace(`Spawning ProxyCommand: ${proxyCommand} ${proxyArgs.join(' ')}`);
155+
let proxyArgs = (sshHostConfig['ProxyCommand'] as unknown as string[])
156+
.map((arg) => arg.replace('%h', sshHostName).replace('%p', sshPort.toString()).replace('%r', sshUser));
157+
let proxyCommand = proxyArgs.shift()!;
160158

161159
let options = {};
162-
if (isWindows && /\.(bat|cmd)"$/.test(proxyCommand)) {
160+
if (isWindows && /\.(bat|cmd)$/.test(proxyCommand)) {
161+
proxyCommand = `"${proxyCommand}"`;
162+
proxyArgs = proxyArgs.map((arg) => arg.includes(' ') ? `"${arg}"` : arg);
163163
options = { shell: true, windowsHide: true, windowsVerbatimArguments: true };
164164
}
165165

166+
this.logger.trace(`Spawning ProxyCommand: ${proxyCommand} ${proxyArgs.join(' ')}`);
167+
166168
const child = cp.spawn(proxyCommand, proxyArgs, options);
167169
proxyStream = stream.Duplex.from({ readable: child.stdout, writable: child.stdin });
168170
this.proxyCommandProcess = child;

0 commit comments

Comments
 (0)