microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.55k stars 263 forks source link

[Remote-SSH Bug]: SSH-Agent Forwarding stoped working #9662

Open Crefok opened 3 months ago

Crefok commented 3 months ago

Is there an existing issue for this bug?

Required Troubleshooting Steps

Connect Locally

It connects successfully

->

No response

Expected Behavior

I would expect to get the ssh-agent forwarded to the ssh client. But that isn't working anymore. If I directly connect to the same Host, the ssh agent is forwarded, and can be used.

Steps To Reproduce

  1. vs-code is updated to the newest version
  2. ssh-config ForwardAgent yes is set
  3. connect to the remote Host via vs code remote extension.
  4. try to connect to another host via integrated terminal an use the forwarded host key

Remote-SSH Log

Remote-SSH Log

``` [16:18:24.113] Log Level: 2 [16:18:24.118] VS Code version: 1.87.2 [16:18:24.118] Remote-SSH version: remote-ssh@0.109.0 [16:18:24.118] darwin arm64 [16:18:24.119] SSH Resolver called for "ssh-remote+edge01", attempt 1 [16:18:24.119] "remote.SSH.useLocalServer": true [16:18:24.119] "remote.SSH.useExecServer": true [16:18:24.119] "remote.SSH.path": undefined [16:18:24.119] "remote.SSH.configFile": undefined [16:18:24.119] "remote.SSH.useFlock": true [16:18:24.119] "remote.SSH.lockfilesInTmp": false [16:18:24.119] "remote.SSH.localServerDownload": auto [16:18:24.119] "remote.SSH.remoteServerListenOnSocket": false [16:18:24.120] "remote.SSH.showLoginTerminal": false [16:18:24.120] "remote.SSH.defaultExtensions": [] [16:18:24.120] "remote.SSH.loglevel": 2 [16:18:24.120] "remote.SSH.enableDynamicForwarding": true [16:18:24.120] "remote.SSH.enableRemoteCommand": false [16:18:24.120] "remote.SSH.serverPickPortsFromRange": {} [16:18:24.120] "remote.SSH.serverInstallPath": {} [16:18:24.123] SSH Resolver called for host: edge01 [16:18:24.123] Setting up SSH remote "edge01" [16:18:24.124] Acquiring local install lock: /var/folders/1_/vy1hm2gn3_z9vpxkgb65z0300000gq/T/vscode-remote-ssh-b74c3d4f-install.lock [16:18:24.125] Looking for existing server data file at /Users//Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-b74c3d4f-863d2581ecda6849923a2118d93a088b0745d9d6-0.109.0-es/data.json [16:18:24.126] Found local server running: {"remoteListeningOn":{"port":40560},"osReleaseId":"rhel","arch":"x86_64","sshAuthSock":"/tmp/ssh-djn2ienDq4/agent.275215","display":"","tmpDir":"/run/user/9264","platform":"linux","execServerToken":"f56215be-b7e7-4472-be03-0b3eb9f05ee2","pid":73244,"ipcHandlePath":"/var/folders/1_/vy1hm2gn3_z9vpxkgb65z0300000gq/T/vscode-ssh-askpass-af3f88910e8059a1d091bf39f1874ce63413ef4a.sock","socksPort":62312,"startupTime":1710514181093} [16:18:24.128] Found running server - short-circuiting install [16:18:24.130] Starting forwarding server. local port 61305 -> socksPort 62312 -> remotePort 40560 [16:18:24.130] Forwarding server listening on port 61305 [16:18:24.130] Waiting for ssh tunnel to be ready [16:18:24.130] Tunneled port 40560 to local port 61305 [16:18:24.130] Resolved "ssh-remote+edge01" to "port 61305" [16:18:24.134] Initizing new exec server for ssh-remote+edge01 [16:18:24.134] Resolving exec server at port 61305 [16:18:24.147] [Forwarding server port 61305] Got connection 0 [16:18:24.147] [Forwarding server port 61305] Got connection 1 [16:18:24.230] Exec server for ssh-remote+edge01 created and cached [16:18:24.232] ------ [16:18:24.257] [server] Checking /home//.vscode-server/cli/servers/Stable-863d2581ecda6849923a2118d93a088b0745d9d6/log.txt and /home//.vscode-server/cli/servers/Stable-863d2581ecda6849923a2118d93a088b0745d9d6/pid.txt for a running server... [16:18:24.296] [server] Found running server (pid=167271) [16:22:34.771] ConfigFileWatcher: start watching file:///Users//.ssh/config [16:22:34.771] ConfigFileWatcher: adding save listener [16:22:34.771] ConfigFileWatcher: adding close listener [16:22:46.175] ConfigFileWatcher: start watching file:///etc/ssh/ssh_config [16:22:55.403] ConfigFileWatcher: closing file:///etc/ssh/ssh_config [16:22:55.403] ConfigFileWatcher: stop watching file:///etc/ssh/ssh_config [16:23:23.641] ConfigFileWatcher: closing file:///Users//.ssh/config [16:23:23.641] ConfigFileWatcher: stop watching file:///Users//.ssh/config [16:23:23.641] ConfigFileWatcher: removing save listener [16:23:23.641] ConfigFileWatcher: removing close listener ```

Anything else?

ssh-add -l via direct ssh connection to the hosts lists the same keys as on the notebook I connected to the host. These Keys are also set so use on other hosts

ssh-add -l got the following output, when used in the VS Code Bash Terminal.

ssh-add -l
Error connecting to agent: No such file or directory

VS Code Version

Version: 1.87.2
Commit: 863d2581ecda6849923a2118d93a088b0745d9d6
Datum: 2024-03-08T15:20:57.520Z (Vor 1 Woche(n))
Electron: 27.3.2
ElectronBuildId: 26836302
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
Betriebssystem: Darwin arm64 23.4.0

With VS Code Version does it work!

Version: 1.86.2
Commit: 903b1e9d8990623e3d7da1df3d33db3e42d80eda
Datum: 2024-02-13T19:42:12.210Z (Vor 1 Monat(en))
Electron: 27.2.3
ElectronBuildId: 26908389
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
Betriebssystem: Darwin arm64 23.4.0
roblourens commented 3 months ago

Does it make a difference if you set "remote.SSH.useExecServer": false?

Crefok commented 3 months ago

Yes If I set this option to false the agent will be forwarded and I can tunnel to the next host

gopipalamalai commented 3 months ago

I have been seeing the issue same as https://github.com/microsoft/vscode/issues/168202 since Mar 22, 2024. Disabling remote.SSH.useExecServer fixed it once. I have to observe over a few more days if this sticks and continues to work. what about remote.ssh.useLocalServerorremote.SSH.enableAgentForwarding ? Do they need to be disabled too as per this https://github.com/microsoft/vscode/issues/175806#issuecomment-1453702918 @roblourens

ssh-add -l
Error connecting to agent: No such file or directory
misl-smlz commented 3 months ago

I had the same issue today. Disabling remote.SSH.useExecServer fixed it for now. Can I help in any way to solve the problem?

berrugo commented 3 months ago

remote.SSH.useExecServer

@roblourens It worked, thanks! Just make sure to reload window afterwards

egfx-notifications commented 3 months ago

Does it make a difference if you set "remote.SSH.useExecServer": false?

I just went back to still available older versions of the extension and

WellWells commented 2 months ago

The same issue is occurring for me as well. I'm using VSCode version 1.88.0 (2024-04-03) along with Remote - SSH version v0.110.1.

I have confirmed that the private key is installed on my local machine, and I can connect normally using "ssh -A user@server" with successful git operations. Previously, when I connected through VSCode, I configured it with "ForwardAgent yes" in the ssh config file, and git operations were working fine.

The current workaround, as described above, involves accessing settings and disabling remote.SSH.useExecServer to resolve this issue.

image
francisrafal commented 2 months ago

Same issue here, also fixed by disabling remote.SSH.useExecServer

tgquan67 commented 2 months ago

Confirmed this problem happened for me with plugin version v0.110.1 on VSCode 1.88.1, Ubuntu 20.04.6. Disabling remote.SSH.useExecServer helped as a workaround.

Crefok commented 2 months ago

If the remote Server has no connection to the Internet then the upgrade Prozess of VSCode Remote Server runs into some timeouts. Current Workaround for me is to disable autoupdate (settings->application->update->update.mode to manuel) and use Version: 1.86.2 of VSCode

0x4c6565 commented 2 months ago

Can confirm remote.SSH.useExecServer solves this for me too, however now prompts for key passphrase? It works without providing passphrase however.

alexisshaw commented 1 month ago

Wanted to comment that this still appears to be an issue for me too, but that "remote.SSH.useExecServer": false seems to solve the issue too.

Since reporting this, I have found that is the connection dies due to the computer going to sleep, upon waking the connection to the SSH agent used for forwarding fails, and the window needs to be reloaded in order to access the windows SSH agent again.

Crefok commented 19 hours ago

Is there a way to pin the Version or disable autoupdate of some extensions? Some of my Extensions require a newer Version of VS Code now and stop working. Are there any news for fixing the issue?