vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

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

Open Crefok opened this issue 11 months ago • 11 comments

Is there an existing issue for this bug?

  • [X] I have searched the existing issues

Required Troubleshooting Steps

  • [X] I have followed these troubleshooting steps
  • [X] I have tried both values of the remote.SSH.useLocalServer setting

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: [email protected]
[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/<USER>/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/<USER>/.vscode-server/cli/servers/Stable-863d2581ecda6849923a2118d93a088b0745d9d6/log.txt and /home/<USER>/.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/<USER>/.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/<USER>/.ssh/config
[16:23:23.641] ConfigFileWatcher: stop watching file:///Users/<USER>/.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

Crefok avatar Mar 15 '24 15:03 Crefok

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

roblourens avatar Mar 20 '24 19:03 roblourens

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

Crefok avatar Mar 21 '24 07:03 Crefok

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.useLocalServer orremote.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

gopipalamalai avatar Mar 26 '24 04:03 gopipalamalai

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

misl-smlz avatar Mar 26 '24 09:03 misl-smlz

remote.SSH.useExecServer

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

berrugo avatar Mar 26 '24 16:03 berrugo

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

  • the first extension version where this happens is the one that introduced the "remote.SSH.useExecServer" setting
  • starting with this version the agent forwarding works again when setting "remote.SSH.useExecServer" to false

egfx-notifications avatar Apr 03 '24 12:04 egfx-notifications

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

WellWells avatar Apr 08 '24 03:04 WellWells

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

francisrafal avatar Apr 09 '24 14:04 francisrafal

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.

tgquan67 avatar Apr 15 '24 08:04 tgquan67

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

Crefok avatar Apr 15 '24 09:04 Crefok

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

0x4c6565 avatar Apr 29 '24 12:04 0x4c6565

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.

alexisshaw avatar May 23 '24 06:05 alexisshaw

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?

Crefok avatar Jul 05 '24 05:07 Crefok

This should be fixed in the latest Remote - SSH prerelease

connor4312 avatar Jul 08 '24 16:07 connor4312