Vscode-remote-release: ssh agent, ForwardAgent not working in Remote-SSH 0.50

Created on 10 Mar 2020  路  13Comments  路  Source: microsoft/vscode-remote-release

Version: 1.43.0 (user setup)
Commit: 78a4c91400152c0f27ba4d363eb56d2835f9903a
Date: 2020-03-09T19:47:57.235Z
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363

Steps to Reproduce:

  1. Use ssh-keygen to generate a private and public key
  2. Add the public key to remote host into .authorized keys
  3. Add the public key to another remote host
  4. Setup .ssh\config locally to allow ForwardAgent
# Enable key forwarding for all known hosts
Host *
    ForwardAgent yes
[...]
  1. Connect to remote host using vscode and SSH Extension.
  2. Open the terminal on the remote and try to connect to

Error:

Permission denied (publickey).

bug ssh verification-steps-needed verified

Most helpful comment

Updating to 0.50.0 and changing the setting "remote.SSH.path" to use "C:\WINDOWS\System32\OpenSSH\ssh.exe" seem to resolve the issue.

So when the SSH.path is undefined it uses the path C:\Program Files\Git\usr\bin\ssh.exe -V?

All 13 comments

I am having the exact same issue. Yesterday when I was using 1.42.1 version I wasn't experiencing any issue at all.

I have reverted to version 0.49 for both Remote - SSH and Remote - SSH Editing Configuration Files modules and the issue is gone. I think this issue is duplicate of https://github.com/microsoft/vscode/issues/92331

iMO it's related but not dup since the remote connection does work for me

@ole1986 can you try this in your local settings?
"remote.SSH.path": "C:\\Windows\\System32\\OpenSSH\\ssh.exe", "remote.SSH.useLocalServer": false
It worked for me with the 0.50 version. Before that I had the same issues with my VM when I was trying to access another host by agent forwarding.

Could you share the log from the Remote-SSH output channel from a run with the latest version when this doesn't work?

[08:24:43.677] Log Level: 2
[08:24:43.689] [email protected]
[08:24:43.689] win32 x64
[08:24:43.693] SSH Resolver called for "ssh-remote+7b22686f73744e616d65223a224c45522d5745422d3120284e65772057656273657276657229227d", attempt 1
[08:24:43.693] SSH Resolver called for host: SERVERNAME
[08:24:43.693] Setting up SSH remote "SERVERNAME"
[08:24:43.699] Acquiring local install lock: C:\Users\OLE~1.KOE\AppData\Local\Temp\vscode-remote-ssh-SERVERNAME-install.lock
[08:24:43.722] Looking for existing server data file at c:\Users\ole.koeckemann\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-ssh\vscode-ssh-host-SERVERNAME-78a4c91400152c0f27ba4d363eb56d2835f9903a\data.json
[08:24:43.725] Found local server running: {"agentPort":35471,"osReleaseId":"debian","arch":"x86_64","webUiAccessToken":"","sshAuthSock":"","tmpDir":"/run/user/1001","platform":"linux","pid":23904,"ipcHandlePath":"\\\\.\\pipe\\vscode-ssh-askpass-96721874d5581de075469a257cea704657179c42-sock","socksPort":65255,"startupTime":1583851885139}
[08:24:43.729] Server delay-shutdown request failed: connect ENOENT \\.\pipe\vscode-ssh-askpass-96721874d5581de075469a257cea704657179c42-sock
[08:24:43.729] Existing server's health check failed, will start a new one
[08:24:43.730] Using commit id "78a4c91400152c0f27ba4d363eb56d2835f9903a" and quality "stable" for server
[08:24:43.731] Install and start server if needed
[08:24:43.739] Checking ssh with "ssh -V"
[08:24:43.864] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[08:24:43.864] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V"
[08:24:43.981] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[08:24:43.981] Checking ssh with "C:\Program Files\Git\usr\bin\ssh.exe -V"
[08:24:44.152] > OpenSSH_8.2p1, OpenSSL 1.1.1d  10 Sep 2019
[08:24:44.155] askpass server listening on \\.\pipe\vscode-ssh-askpass-bd498d7a9b378dc001fd2294bbf26f1c83084802-sock
[08:24:44.156] Spawning local server with {"ipcHandlePath":"\\\\.\\pipe\\vscode-ssh-askpass-87d5d28f86b2a1be2f6c5b2b4eb53a5ddaba5e9a-sock","sshCommand":"C:\\Program Files\\Git\\usr\\bin\\ssh.exe","sshArgs":["-v","-T","-D","53201","SERVERNAME"],"dataFilePath":"c:\\Users\\ole.koeckemann\\AppData\\Roaming\\Code\\User\\globalStorage\\ms-vscode-remote.remote-ssh\\vscode-ssh-host-SERVERNAME-78a4c91400152c0f27ba4d363eb56d2835f9903a\\data.json"}
[08:24:44.156] Local server env: {"DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"c:\\Users\\ole.koeckemann\\.vscode\\extensions\\ms-vscode-remote.remote-ssh-0.50.0\\out\\local-server\\askpass.bat","VSCODE_SSH_ASKPASS_NODE":"C:\\Users\\ole.koeckemann\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe","VSCODE_SSH_ASKPASS_MAIN":"c:\\Users\\ole.koeckemann\\.vscode\\extensions\\ms-vscode-remote.remote-ssh-0.50.0\\out\\askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"\\\\.\\pipe\\vscode-ssh-askpass-bd498d7a9b378dc001fd2294bbf26f1c83084802-sock"}
[08:24:44.167] Spawned 10908
[08:24:44.322] > local-server> Spawned ssh: 11268
[08:24:44.423] stderr> OpenSSH_8.2p1, OpenSSL 1.1.1d  10 Sep 2019
[08:24:44.518] stderr> debug1: Server host key: ecdsa-sha2-nistp256 SHA256:wWr2cqV5K+CZsvHI1FmYPZVu1jHenc+Hmwf/ksvfD34
[08:24:44.594] stderr> Authenticated to 172.20.50.45 ([172.20.50.45]:22).
[08:24:44.959] > Linux ler-web-1-new 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64
> 
> The programs included with the Debian GNU/Linux system are free software;
> the exact distribution terms for each program are described in the
> individual files in /usr/share/doc/*/copyright.
> 
> Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
> permitted by applicable law.
[08:24:44.961] > ready: fd0eaf763c9b
[08:24:44.967] > Linux 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26)
[08:24:44.968] Platform: linux
[08:24:44.993] > fd0eaf763c9b: running
[08:24:45.012] > Acquiring lock on /home/webdev/.vscode-server/bin/78a4c91400152c0f27ba4d363eb56d2835f9903a/vscode-remote-lock.webdev.78a4c91400152c0f27ba4d363eb56d2835f9903a
[08:24:45.014] > \ln /home/webdev/.vscode-server/bin/78a4c91400152c0f27ba4d363eb56d2835f9903a/vscode-remote-lock.webdev.78a4c91400152c0f27ba4d363eb56d2835f9903a.target /home/webdev/.vscode-server/bin/78a4c91400152c0f27ba4d363eb56d2835f9903a/vscode-remote-lock.webdev.78a4c91400152c0f27ba4d363eb56d2835f9903a
[08:24:45.022] > Found existing installation at /home/webdev/.vscode-server/bin/78a4c91400152c0f27ba4d363eb56d2835f9903a...
[08:24:45.034] > SHELL=/bin/bash
> LANGUAGE=en_US:en
> PWD=/home/webdev
> LOGNAME=webdev
> XDG_SESSION_TYPE=tty
> HOME=/home/webdev
> LANG=en_US.UTF-8
> VSCODE_AGENT_FOLDER=/home/webdev/.vscode-server
> SSH_CONNECTION=172.20.30.129 53203 172.20.50.45 22
> XDG_SESSION_CLASS=user
> USER=webdev
> SHLVL=2
> XDG_SESSION_ID=141
> XDG_RUNTIME_DIR=/run/user/1001
> SSH_CLIENT=172.20.30.129 53203 22
> PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
> MAIL=/var/mail/webdev
> _=/usr/bin/printenv
> Starting server with command... /home/webdev/.vscode-server/bin/78a4c91400152c0f27ba4d363eb56d2835f9903a/server.sh --host=127.0.0.1 --enable-remote-auto-shutdown  --port=0 &> "/home/webdev/.vscode-server/.78a4c91400152c0f27ba4d363eb56d2835f9903a.log" < /dev/null
[08:24:45.038] > Waiting for server log...
[08:24:45.547] > Waiting for server log...
[08:24:46.059] >  
> *
> * Reminder: You may only use this software with Visual Studio family products,
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
> *
>  
> fd0eaf763c9b: start
> sshAuthSock====
> agentPort==36577==
> osReleaseId==debian==
> arch==x86_64==
> webUiAccessToken====
> tmpDir==/run/user/1001==
> platform==linux==
> fd0eaf763c9b: end
[08:24:46.060] Received install output: 
sshAuthSock====
agentPort==36577==
osReleaseId==debian==
arch==x86_64==
webUiAccessToken====
tmpDir==/run/user/1001==
platform==linux==

[08:24:46.062] Remote server is listening on port 36577
[08:24:46.062] Parsed server configuration: {"agentPort":36577,"osReleaseId":"debian","arch":"x86_64","webUiAccessToken":"","sshAuthSock":"","tmpDir":"/run/user/1001","platform":"linux"}
[08:24:46.064] Persisting server connection details to c:\Users\ole.koeckemann\AppData\Roaming\Code\User\globalStorage\ms-vscode-remote.remote-ssh\vscode-ssh-host-SERVERNAME-78a4c91400152c0f27ba4d363eb56d2835f9903a\data.json
[08:24:46.069] Starting forwarding server. localPort 53206 -> socksPort 53201 -> remotePort 36577
[08:24:46.072] Forwarding server listening on 53206
[08:24:46.073] Waiting for ssh tunnel to be ready
[08:24:46.077] Tunneled remote port 36577 to local port 53206
[08:24:46.078] Resolved "ssh-remote+7b22686f73744e616d65223a224c45522d5745422d3120284e65772057656273657276657229227d" to "127.0.0.1:53206"
[08:24:46.080] [Forwarding server 53206] Got connection 0
[08:24:46.092] ------

Switching back ms-vscode-remote.remote-ssh to version 0.49.0 fixed it

Could you check whether setting "remote.SSH.path": "C:\\WINDOWS\\System32\\OpenSSH\\ssh.exe" would also fix it in the latest version?

Updating to 0.50.0 and changing the setting "remote.SSH.path" to use "C:\WINDOWS\System32\OpenSSH\ssh.exe" seem to resolve the issue.

So when the SSH.path is undefined it uses the path C:\Program Files\Git\usr\bin\ssh.exe -V?

I'm using 0.50.0 and was experiencing similar issues as noted in #2521. My remote.SSH.path was initially blank. After changing it to C:\WINDOWS\System32\OpenSSH\ssh.exe it resolved my issues as well, namely:

  • Key passwords are now managed by the Windows OpenSSH agent. You must add them with ssh-add. Once added, they are used by Remote - SSH extension. I am required to enter the key password if and only if key is not listed in ssh-add -l.
  • Keys are forwarded to the remote connections.

Just like with the other commenters, changing my remote.SSH.path to "C:\\Windows\\System32\\OpenSSH\\ssh.exe" fixed the issue.

If using OpenSSH by default (if available) is not an option, could VSCode Remote intelligently prompt the user about which SSH agent they'd like to use?

We detected SSH installed. Would you like to use that instead of Git's SSH?

More info
[Use OpenSSH] [Continue using Git's SSH]

Or it could detect other ssh-added keys in one of the two known agents and prompt if more exist:

Tried using OpenSSH to connect, but there are other keys in Git's SSH. Would you like to switch?

More info
[Use Git's SSH] [Continue using OpenSSH]

Optimally VSCode Remote could figure it all out for me, though :).

Considering this fixed in 0.51. If remote.SSH.useLocalServer: true is set to override the default then the problem will still exist.

Can anyone confirm that this is working as expected now?

Was this page helpful?
0 / 5 - 0 ratings