From 78781fbbbf1e9407e5a7c27e779aba22c1fe9f10 Mon Sep 17 00:00:00 2001 From: Jean Pierre Date: Sat, 30 Sep 2023 19:04:48 -0500 Subject: [PATCH] Fix ProxyCommand on windows --- src/authResolver.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/authResolver.ts b/src/authResolver.ts index eff12d3..5bd1a20 100644 --- a/src/authResolver.ts +++ b/src/authResolver.ts @@ -153,12 +153,17 @@ export class RemoteSSHResolver implements vscode.RemoteAuthorityResolver, vscode } } else if (sshHostConfig['ProxyCommand']) { const proxyArgs = (sshHostConfig['ProxyCommand'] as unknown as string[]) - .map((arg) => arg.replace('%h', sshHostName).replace('%p', sshPort.toString()).replace('%r', sshUser)); + .map((arg) => `"${arg.replace('%h', sshHostName).replace('%p', sshPort.toString()).replace('%r', sshUser)}"`); const proxyCommand = proxyArgs.shift()!; this.logger.trace(`Spawning ProxyCommand: ${proxyCommand} ${proxyArgs.join(' ')}`); - const child = cp.spawn(proxyCommand, proxyArgs, { windowsHide: true, windowsVerbatimArguments: true }); + let options = {}; + if (isWindows && /\.(bat|cmd)"$/.test(proxyCommand)) { + options = { shell: true, windowsHide: true, windowsVerbatimArguments: true }; + } + + const child = cp.spawn(proxyCommand, proxyArgs, options); proxyStream = stream.Duplex.from({ readable: child.stdout, writable: child.stdin }); this.proxyCommandProcess = child; } @@ -175,7 +180,7 @@ export class RemoteSSHResolver implements vscode.RemoteAuthorityResolver, vscode strictVendor: false, agentForward, agent, - authHandler: (arg0, arg1, arg2) => (sshAuthHandler(arg0, arg1, arg2), undefined) + authHandler: (arg0, arg1, arg2) => (sshAuthHandler(arg0, arg1, arg2), undefined), }); await this.sshConnection.connect();