VSCode ssh connection to local wsl2 devcontainer timed out
What happened?
Tried to start DevContainer from this repo: https://github.com/microsoft/vscode-remote-try-python.git with SSH Provider. Devcontainer started successfully in my local WSL2, Ubuntu 22.04, but ssh connection from my started VSCode (Windows) timed out.
DevPod log with --debug:
[14:19:33] debug Done creating devcontainer
[14:19:33] info Run 'ssh vscode-remote-try-python.devpod' to ssh into the devcontainer
[14:19:33] debug No dotfiles repo specified, skipping
[14:19:33] info Starting VSCode...
[14:19:34] debug Run vscode command code --disable-extension ms-vscode-remote.remote-containers --new-window --folder-uri=vscode-remote://ssh-remote+vscode-remote-try-python.devpod//workspaces/vscode-remote-try-python
VSCode log:
[14:19:45.457] Running script with connection command: "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 50566 "vscode-remote-try-python.devpod" bash
[14:19:45.460] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[14:20:02.465] Resolver error: Error: Connecting with SSH timed out
at g.Timeout (c:\Users\chris\.vscode\extensions\ms-vscode-remote.remote-ssh-0.106.5\out\extension.js:2:641063)
at Timeout._onTimeout (c:\Users\chris\.vscode\extensions\ms-vscode-remote.remote-ssh-0.106.5\out\extension.js:2:758900)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7)
[14:20:02.483] ------
[14:20:06.155] > 14:20:06[38;5;6minfoWaiting for devpod agent to come up...
> ]0;C:\WINDOWS\System32\cmd.exe
[14:20:06.156] Got some output, clearing connection timeout
[14:20:06.175] > 14:20:06 [38;5;6minfo Waiting for devpod agent to come up...
What did you expect to happen instead?
SSH Connection established successfully
How can we reproduce the bug? (as minimally and precisely as possible)
Create ssh keys on windows and add the pub to authorized_keys on the wsl ubuntu distribution Configure SSH Agent in DevPod to use localhost and port 22. Everything else default:
"provider": {
"name": "ssh",
"options": {
"AGENT_PATH": {
"value": "/tmp/devpod/agent",
"userProvided": true
},
"DOCKER_PATH": {
"value": "docker",
"userProvided": true
},
"EXTRA_FLAGS": {
"userProvided": true
},
"HOST": {
"value": "localhost",
"userProvided": true
},
"INACTIVITY_TIMEOUT": {
"userProvided": true
},
"INJECT_DOCKER_CREDENTIALS": {
"value": "true",
"userProvided": true
},
"INJECT_GIT_CREDENTIALS": {
"value": "true",
"userProvided": true
},
"PORT": {
"value": "22",
"userProvided": true
}
}
},
Create workspace with git url: https://github.com/microsoft/vscode-remote-try-python.git and VSCode
Local Environment:
- DevPod Version: v0.4.0-alpha.5
- Operating System: Windows 11 Home
- WSL2 with Ubuntu 22.04 and OpenSSH Server:
WSL-Version: 2.0.5.0
Kernelversion: 5.15.133.1-1
WSLg-Version: 1.0.59
MSRDC-Version: 1.2.4485
Direct3D-Version: 1.608.2-61064218
DXCore-Version: 10.0.25880.1000-230602-1350.main
Windows-Version: 10.0.22621.2428
- ARCH of the OS: AMD64
DevPod Provider:
- Local/remote provider: ssh
Anything else we need to know?
DevPod adds a host to the ssh config:
PS C:\Users\chris.ssh> cat .\config
...
# DevPod Start vscode-remote-try-python.devpod
Host vscode-remote-try-python.devpod
ForwardAgent yes
LogLevel error
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
ProxyCommand C:\Program Files\DevPod\devpod-cli.exe ssh --stdio --context default --user vscode vscode-remote-try-python
When executing ssh with this host, this happens:
PS C:\Program Files\DevPod> ssh vscode-remote-try-python.devpod
14:51:22 info Waiting for devpod agent to come up...
14:51:45 info Waiting for devpod agent to come up...
14:52:08 info Waiting for devpod agent to come up...
14:52:31 info Waiting for devpod agent to come up...
14:52:54 info Waiting for devpod agent to come up...
When executing the proxy command in ps (using devpod.cmd instead of the path to exe), this happens:
PS C:\Users\chris> devpod.cmd ssh --debug --stdio --context default --user vscode vscode-remote-try-python
13:52:53 debug Adding ssh keys to agent, disable via 'devpod context set-options -o SSH_ADD_PRIVATE_KEYS=false'
13:52:53 debug Error adding private keys to ssh-agent: ssh-agent is not started
13:52:53 debug Acquire workspace lock...
13:52:53 debug Acquired workspace lock...
13:52:53 debug execute inject script
13:52:53 debug download agent from https://github.com/loft-sh/devpod/releases/download/v0.4.0-alpha.5
13:52:53 debug Run command provider command: ${SSH_PROVIDER} command
13:52:54 debug Received line after pong: done
13:52:54 debug Successfully connected to host
13:52:54 debug Run container tunnel
13:52:54 info Execute SSH server command: bash -c '/tmp/devpod/agent' agent container-tunnel --workspace-info 'H4sIAAAAAAAA/+xTXW/aShD9L/ts4w++Yr8hwiXcmwsRMVVbrYSW3THeZu21dtYkEeK/V4uTlLaQSn2r1Mexz5k5s3POnjxq84A140DSPZGCpGSHXAvwDZTagm/Ns18/20JXxCPNuwBfQM4aZX3h55s8viIeybUSYEhKximlKwSDlPLCSKS0I2BXa0Ep15WFJ4uUvvApfROFlL4jp5bcNgZISgpra0yDQNdQbQ2ri85W2qLZMESw2OG6DGAgNmzTiwfAo8EAumHST0QikijaDDfRFUAS5r0QeJiE/d4wGfZyFvW5GLKkm3SjfhyUkhuNOrfBe5KM3snjyntSsdJpQyyIR3Rtpa7QfR9NJ/NsfTfKbly1Y6pxsMCWddC+ScC2UFn33gjmru0oSGpNAwePXC/G/02WP/GF5g9gLpEmH7PlaP3P7Wh670hnMTeL++y0o9KcqULjRSWz+WiczT7Msk/rbPb/ZLHKLvaezf+djLP1i/bxcnI9mWez0e396UCHvTzr2GA6y36HfbdYfrdaHJ9HHg4eKRkvZOXycPCIFHByyvbw5OAR1I1pM7OVdgm1Rmm1eT6xYmvAo/V+7RxnV9eWG2DOJ5ksAS0ra6c1jLt+FPpxL4uiNOym4eAz8YhiaFfolP+A6Mdpv+sQL8Fy3miD5Sa01kr3pGa2uGA7oR8rpZlYLW/PL6R0bn0sXnkGFDAEDF6JwS7s9Dqhz1RdsE6feERWX4DbqbRjAwIqK5nCbzdr/14fHXwWAE/A24O0NleAeFqfLPSWA1mhZUqRlORM4fFqvEGrS0d0hZKLt1Ae/ib0T0noVwAAAP//AQAA//9WtvKOtAYAAA==' --debug
13:52:54 info No root required, because neither docker nor agent daemon needs to be installed
13:52:54 info Use /home/ckihm/.devpod/agent/contexts/default/workspaces/vscode-remote-try-python as workspace dir
13:52:54 info Using docker command 'docker'
13:52:54 info execute inject script
13:52:54 info Received line after pong: done
13:52:54 info done inject
13:52:54 info done injecting
13:52:54 info Done InjectAgentAndExecute
13:52:54 info done exec
13:52:54 debug Successfully connected to container
13:52:54 debug Run outer container tunnel
13:52:54 info Execute SSH server command: bash -c cat /var/run/devpod/result.json
13:52:54 info Execute SSH server command: bash -c su -c "'/usr/local/bin/devpod' helper ssh-server --track-activity --stdio --debug" 'vscode'
13:52:54 debug Successfully parsed result at /var/run/devpod/result.json
13:52:54 info Execute SSH server command: bash -c '/usr/local/bin/devpod' agent container credentials-server --user 'vscode' --configure-docker-helper --debug
13:52:54 debug Received ping from agent
13:52:54 debug Start credentials server
13:52:54 debug Wrote docker credentials helper to /usr/local/bin/docker-credential-devpod
SSH-2.0-Go
13:52:55 debug Credentials server started on port 17267...
13:53:24 debug Start refresh
13:53:24 debug Run command in container: '/tmp/devpod/agent' agent workspace update-config --workspace-info 'H4sIAAAAAAAA/+xTXW/aShD9L/ts4w++Yr8hwiXcmwsRMVVbrYSW3THeZu21dtYkEeK/V4uTlLaQSn2r1Mexz5k5s3POnjxq84A140DSPZGCpGSHXAvwDZTagm/Ns18/20JXxCPNuwBfQM4aZX3h55s8viIeybUSYEhKximlKwSDlPLCSKS0I2BXa0Ep15WFJ4uUvvApfROFlL4jp5bcNgZISgpra0yDQNdQbQ2ri85W2qLZMESw2OG6DGAgNmzTiwfAo8EAumHST0QikijaDDfRFUAS5r0QeJiE/d4wGfZyFvW5GLKkm3SjfhyUkhuNOrfBe5KM3snjyntSsdJpQyyIR3Rtpa7QfR9NJ/NsfTfKbly1Y6pxsMCWddC+ScC2UFn33gjmru0oSGpNAwePXC/G/02WP/GF5g9gLpEmH7PlaP3P7Wh670hnMTeL++y0o9KcqULjRSWz+WiczT7Msk/rbPb/ZLHKLvaezf+djLP1i/bxcnI9mWez0e396UCHvTzr2GA6y36HfbdYfrdaHJ9HHg4eKRkvZOXycPCIFHByyvbw5OAR1I1pM7OVdgm1Rmm1eT6xYmvAo/V+7RxnV9eWG2DOJ5ksAS0ra6c1jLt+FPpxL4uiNOym4eAz8YhiaFfolP+A6Mdpv+sQL8Fy3miD5Sa01kr3pGa2uGA7oR8rpZlYLW/PL6R0bn0sXnkGFDAEDF6JwS7s9Dqhz1RdsE6feERWX4DbqbRjAwIqK5nCbzdr/14fHXwWAE/A24O0NleAeFqfLPSWA1mhZUqRlORM4fFqvEGrS0d0hZKLt1Ae/ib0T0noVwAAAP//AQAA//9WtvKOtAYAAA=='
These manual steps are working:
- open vscode on windows and open ssh connection to wsl with remote extention
- connect to running devcontainer (created by devpod)
I should add that opening the same devcontainer with vscode (browser) instead of vscode does work.
Hi @ckihm to understand, you're using the ssh provider to connect from the windows host to the WSL environment?
Hi @89luca89 yes thats correct. Tested the same workspace with the ssh provider successfully with vscode browser, intellij and fleet. Just vscode is having this problem
I think I have the same issue, though the SSH provider is on another machine.
[08:39:44.213] Log Level: 2
[08:39:44.230] VS Code version: 1.83.1
[08:39:44.230] Remote-SSH version: [email protected]
[08:39:44.230] win32 x64
[08:39:44.236] SSH Resolver called for "ssh-remote+vscode-remote-try-rust.devpod", attempt 1
[08:39:44.238] "remote.SSH.useLocalServer": false
[08:39:44.238] "remote.SSH.useExecServer": false
[08:39:44.239] "remote.SSH.showLoginTerminal": false
[08:39:44.239] "remote.SSH.remotePlatform": {"192.168.1.205":"linux"}
[08:39:44.239] "remote.SSH.path": undefined
[08:39:44.240] "remote.SSH.configFile": undefined
[08:39:44.240] "remote.SSH.useFlock": true
[08:39:44.240] "remote.SSH.lockfilesInTmp": false
[08:39:44.241] "remote.SSH.localServerDownload": auto
[08:39:44.241] "remote.SSH.remoteServerListenOnSocket": false
[08:39:44.241] "remote.SSH.showLoginTerminal": false
[08:39:44.242] "remote.SSH.defaultExtensions": []
[08:39:44.242] "remote.SSH.loglevel": 2
[08:39:44.242] "remote.SSH.enableDynamicForwarding": true
[08:39:44.243] "remote.SSH.enableRemoteCommand": false
[08:39:44.243] "remote.SSH.serverPickPortsFromRange": {}
[08:39:44.243] "remote.SSH.serverInstallPath": {}
[08:39:44.250] SSH Resolver called for host: vscode-remote-try-rust.devpod
[08:39:44.250] Setting up SSH remote "vscode-remote-try-rust.devpod"
[08:39:44.254] Using commit id "f1b07bd25dfad64b0167beb15359ae573aecd2cc" and quality "stable" for server
[08:39:44.260] Install and start server if needed
[08:39:46.439] Checking ssh with "C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin\ssh.exe -V"
[08:39:46.442] Got error from ssh: spawn C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin\ssh.exe ENOENT
[08:39:46.442] Checking ssh with "C:\Program Files\Eclipse Adoptium\jdk-11.0.16.101-hotspot\bin\ssh.exe -V"
[08:39:46.443] Got error from ssh: spawn C:\Program Files\Eclipse Adoptium\jdk-11.0.16.101-hotspot\bin\ssh.exe ENOENT
[08:39:46.443] Checking ssh with "C:\WINDOWS\system32\ssh.exe -V"
[08:39:46.445] Got error from ssh: spawn C:\WINDOWS\system32\ssh.exe ENOENT
[08:39:46.445] Checking ssh with "C:\WINDOWS\ssh.exe -V"
[08:39:46.446] Got error from ssh: spawn C:\WINDOWS\ssh.exe ENOENT
[08:39:46.446] Checking ssh with "C:\WINDOWS\System32\Wbem\ssh.exe -V"
[08:39:46.447] Got error from ssh: spawn C:\WINDOWS\System32\Wbem\ssh.exe ENOENT
[08:39:46.447] Checking ssh with "C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe -V"
[08:39:46.448] Got error from ssh: spawn C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT
[08:39:46.448] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V"
[08:39:46.476] > OpenSSH_for_Windows_8.6p1, LibreSSL 3.4.3
[08:39:46.481] Running script with connection command: "C:\WINDOWS\System32\OpenSSH\ssh.exe" -T -D 57952 "vscode-remote-try-rust.devpod" bash
[08:39:46.485] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[08:40:03.497] Resolver error: Error: Connecting with SSH timed out
at g.Timeout (c:\Users\pytha\.vscode\extensions\ms-vscode-remote.remote-ssh-0.106.5\out\extension.js:2:641063)
at Timeout._onTimeout (c:\Users\pytha\.vscode\extensions\ms-vscode-remote.remote-ssh-0.106.5\out\extension.js:2:758900)
at listOnTimeout (node:internal/timers:569:17)
at process.processTimers (node:internal/timers:512:7)
[08:40:03.503] ------
Same here, ssh to another machine.
`[21:13:52.888] Log Level: 2 [21:13:52.953] VS Code version: 1.84.0 [21:13:52.954] Remote-SSH version: [email protected] [21:13:52.954] win32 x64 [21:13:53.006] SSH Resolver called for "ssh-remote+rust-test.devpod", attempt 1 [21:13:53.007] "remote.SSH.useLocalServer": false [21:13:53.007] "remote.SSH.useExecServer": false [21:13:53.008] "remote.SSH.showLoginTerminal": false [21:13:53.008] "remote.SSH.remotePlatform": {} [21:13:53.008] "remote.SSH.path": undefined [21:13:53.009] "remote.SSH.configFile": undefined [21:13:53.009] "remote.SSH.useFlock": true [21:13:53.010] "remote.SSH.lockfilesInTmp": false [21:13:53.010] "remote.SSH.localServerDownload": auto [21:13:53.011] "remote.SSH.remoteServerListenOnSocket": false [21:13:53.011] "remote.SSH.showLoginTerminal": false [21:13:53.012] "remote.SSH.defaultExtensions": [] [21:13:53.012] "remote.SSH.loglevel": 2 [21:13:53.013] "remote.SSH.enableDynamicForwarding": true [21:13:53.014] "remote.SSH.enableRemoteCommand": false [21:13:53.014] "remote.SSH.serverPickPortsFromRange": {} [21:13:53.015] "remote.SSH.serverInstallPath": {} [21:13:53.037] SSH Resolver called for host: rust-test.devpod [21:13:53.037] Setting up SSH remote "rust-test.devpod" [21:13:53.066] Using commit id "d037ac076cee195194f93ce6fe2bdfe2969cc82d" and quality "stable" for server [21:13:53.079] Install and start server if needed [21:13:56.713] Checking ssh with "C:\Python311\Scripts\ssh.exe -V" [21:13:56.725] Got error from ssh: spawn C:\Python311\Scripts\ssh.exe ENOENT [21:13:56.727] Checking ssh with "C:\Python311\ssh.exe -V" [21:13:56.738] Got error from ssh: spawn C:\Python311\ssh.exe ENOENT [21:13:56.738] Checking ssh with "C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin\ssh.exe -V" [21:13:56.769] Got error from ssh: spawn C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin\ssh.exe ENOENT [21:13:56.771] Checking ssh with "C:\Program Files\Common Files\Oracle\Java\javapath\ssh.exe -V" [21:13:56.798] Got error from ssh: spawn C:\Program Files\Common Files\Oracle\Java\javapath\ssh.exe ENOENT [21:13:56.799] Checking ssh with "C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe -V" [21:13:56.808] Got error from ssh: spawn C:\Program Files (x86)\Common Files\Oracle\Java\javapath\ssh.exe ENOENT [21:13:56.809] Checking ssh with "C:\Program Files\PostgreSQL\13\bin\ssh.exe -V" [21:13:56.818] Got error from ssh: spawn C:\Program Files\PostgreSQL\13\bin\ssh.exe ENOENT [21:13:56.819] Checking ssh with "C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler\ssh.exe -V" [21:13:56.882] Got error from ssh: spawn C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler\ssh.exe ENOENT [21:13:56.887] Checking ssh with "C:\windows\system32\ssh.exe -V" [21:13:56.895] Got error from ssh: spawn C:\windows\system32\ssh.exe ENOENT [21:13:56.898] Checking ssh with "C:\windows\ssh.exe -V" [21:13:56.906] Got error from ssh: spawn C:\windows\ssh.exe ENOENT [21:13:56.907] Checking ssh with "C:\windows\System32\Wbem\ssh.exe -V" [21:13:56.913] Got error from ssh: spawn C:\windows\System32\Wbem\ssh.exe ENOENT [21:13:56.915] Checking ssh with "C:\windows\System32\WindowsPowerShell\v1.0\ssh.exe -V" [21:13:56.925] Got error from ssh: spawn C:\windows\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT [21:13:56.926] Checking ssh with "C:\windows\System32\OpenSSH\ssh.exe -V" [21:13:57.144] > OpenSSH_f [21:13:57.146] > or_Windows_8.6p1, LibreSSL 3.4.3
[21:13:57.167] Running script with connection command: "C:\windows\System32\OpenSSH\ssh.exe" -T -D 61416 "rust-test.devpod" bash [21:13:57.176] Terminal shell path: C:\WINDOWS\System32\cmd.exe [21:14:14.187] Resolver error: Error: Connecting with SSH timed out at g.Timeout (c:\Users\biche.vscode\extensions\ms-vscode-remote.remote-ssh-0.107.0\out\extension.js:2:642416) at Timeout._onTimeout (c:\Users\biche.vscode\extensions\ms-vscode-remote.remote-ssh-0.107.0\out\extension.js:2:760318) at listOnTimeout (node:internal/timers:569:17) at process.processTimers (node:internal/timers:512:7) [21:14:14.209] ------
[21:14:20.289] > 21:14:20[38;5;6minfoWaiting for devpod agent to come up...
]0;C:\WINDOWS\System32\cmd.exe [21:14:20.291] Got some output, clearing connection timeout `
Actually, on windows, ssh to wsl container directly trigger some error, which consequentially cause vscode timeout. I added --debug to ssh config so I can see the log. here it is
18:11:07 debug Acquire workspace lock...
18:11:07 debug Acquired workspace lock...
18:11:07 debug execute inject script
18:11:07 debug download agent from https://github.com/loft-sh/devpod/releases/download/v0.4.1
18:11:07 debug Run command provider command: ${SSH_PROVIDER} command
18:11:27 debug done inject
18:11:27 debug done injecting
18:11:27 info Waiting for devpod agent to come up...
18:11:27 debug Inject Error: Warning: Permanently added '[127.0.0.1]:2222' (ED25519) to the list of known hosts.
context deadline exceeded
18:11:30 debug execute inject script
Update. Actually, I believe ssh workspace.devpod function on windows is broken. However, devpod ssh workspace is working as a standalone application, but in ProxyCommand as an ssh option, it doesn't work.
Having the very same issue where the workspace opens up perfectly with vscode browser but when you use the Remote SSH option it just goes into waiting and eventually timeout
19:35:13 info Waiting for devpod agent to come up...
19:35:36 info Waiting for devpod agent to come up...
19:35:59 info Waiting for devpod agent to come up...
19:36:23 info Waiting for devpod agent to come up...
19:36:46 info Waiting for devpod agent to come up...
If anyone else has found a fix for this or the cause for it, please do share.
Still seeing issue in 0.5.2 See https://github.com/loft-sh/devpod/issues/808#issuecomment-1935668762
You are opening VScode in windows, so its needs to access the devcontainer inside WSL2:
I got it working with this fix:
You can create ssh.bat file under windows with the content:
C:\Windows\system32\wsl.exe ssh %*
And then set VS Code setting "remote.SSH.path" to point to that bat file.
But fails more like a workaround than a fix.
@JeanPoll This is a good finding. I now guess it is somehow an string escape issue. For example, on both mac and linux ssh config, a subcommand from ssh can be invoked as \$(subcommand), but on windows ssh config, this has to be \\$(subcommand). I tested your bat and confirmed that I need remove one \ when using ssh client inside a WSL distro.
Anyway I still encounter issues with WSL2 and VScode in windows:
So I do have ubuntu 22.04 in WSL with podman and devcontainer installed.
When I do devpod up it opens VScode in windows, with the SSH trick it's able to connect.
But when you close VScode and try an other time it fails. Still something I need to debug.