devpod icon indicating copy to clipboard operation
devpod copied to clipboard

Could not establish connection to "test-repo.devpod" in WSL2

Open solairen opened this issue 1 year ago • 2 comments

Hi,

I have a problem with running devpod under WSL2. I try to use provider ssh or kubernetes but when I run it under WSL2 I got error:

Could not establish connection to "test-repo.devpod".

But when I run it under Windows it works mostly perfect (I'm unable to pass .ssh and .gnupg keys to container)

Versions OS: Windows 11 WSL: WSL2 - Ubuntu 22.04 DevPod: 0.5.16 DEvPod-CLI: 0.5.16

Logs:

[23:21:27.967] VS Code version: 1.90.2
[23:21:27.968] Remote-SSH version: [email protected]
[23:21:27.968] win32 x64
[23:21:27.972] SSH Resolver called for "ssh-remote+test-repo.devpod", attempt 1
[23:21:27.973] "remote.SSH.useLocalServer": false
[23:21:27.973] "remote.SSH.useExecServer": true
[23:21:27.973] "remote.SSH.showLoginTerminal": false
[23:21:27.973] "remote.SSH.remotePlatform": {"npm":"linux","development":"linux","test-repo.devpod":"linux"}
[23:21:27.973] "remote.SSH.path": undefined
[23:21:27.973] "remote.SSH.configFile": undefined
[23:21:27.973] "remote.SSH.useFlock": true
[23:21:27.973] "remote.SSH.lockfilesInTmp": false
[23:21:27.973] "remote.SSH.localServerDownload": auto
[23:21:27.974] "remote.SSH.remoteServerListenOnSocket": false
[23:21:27.975] "remote.SSH.showLoginTerminal": false
[23:21:27.975] "remote.SSH.defaultExtensions": []
[23:21:27.975] "remote.SSH.loglevel": 2
[23:21:27.975] "remote.SSH.enableDynamicForwarding": true
[23:21:27.975] "remote.SSH.enableRemoteCommand": false
[23:21:27.975] "remote.SSH.serverPickPortsFromRange": {}
[23:21:27.975] "remote.SSH.serverInstallPath": {}
[23:21:27.982] SSH Resolver called for host: test-repo.devpod
[23:21:27.982] Setting up SSH remote "test-repo.devpod"
[23:21:27.984] Using commit id "5437499feb04f7a586f677b155b039bc2b3669eb" and quality "stable" for server
[23:21:27.986] Install and start server if needed
[23:21:27.988] Checking ssh with "C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin\ssh.exe -V"
[23:21:27.990] Got error from ssh: spawn C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin\ssh.exe ENOENT
[23:21:27.990] Checking ssh with "C:\Windows\system32\ssh.exe -V"
[23:21:27.991] Got error from ssh: spawn C:\Windows\system32\ssh.exe ENOENT
[23:21:27.991] Checking ssh with "C:\Windows\ssh.exe -V"
[23:21:27.992] Got error from ssh: spawn C:\Windows\ssh.exe ENOENT
[23:21:27.992] Checking ssh with "C:\Windows\System32\Wbem\ssh.exe -V"
[23:21:27.993] Got error from ssh: spawn C:\Windows\System32\Wbem\ssh.exe ENOENT
[23:21:27.993] Checking ssh with "C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe -V"
[23:21:27.994] Got error from ssh: spawn C:\Windows\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT
[23:21:27.994] Checking ssh with "C:\Windows\System32\OpenSSH\ssh.exe -V"
[23:21:28.013] > OpenSSH_for_Windows_8.6p1, LibreSSL 3.4.3

[23:21:28.017] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 57750 "test-repo.devpod" bash
[23:21:28.018] Terminal shell path: C:\Windows\System32\cmd.exe
[23:21:28.272] > ssh: Could not resolve hostname test-repo.devpod: Nieznany host.
> The process tried to write to a nonexistent pipe.
> ]0;C:\Windows\System32\cmd.exe
[23:21:28.272] Got some output, clearing connection timeout
[23:21:29.523] "install" terminal command done
[23:21:29.524] Install terminal quit with output: ]0;C:\Windows\System32\cmd.exe
[23:21:29.524] Received install output: ]0;C:\Windows\System32\cmd.exe
[23:21:29.524] Failed to parse remote port from server output
[23:21:29.525] Resolver error: Error: 
	at g.Create (c:\Users\michal\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:499918)
	at t.handleInstallOutput (c:\Users\michal\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:497240)
	at t.tryInstall (c:\Users\michal\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:621085)
	at async c:\Users\michal\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:580730
	at async t.withShowDetailsEvent (c:\Users\michal\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:584036)
	at async k (c:\Users\michal\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:577649)
	at async t.resolve (c:\Users\michal\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:581407)
	at async c:\Users\michal\.vscode\extensions\ms-vscode-remote.remote-ssh-0.112.0\out\extension.js:2:848023
[23:21:29.527] ------




[23:21:30.238] Opening exec server for ssh-remote+test-repo.devpod
[23:21:30.326] Initizing new exec server for ssh-remote+test-repo.devpod
[23:21:30.341] Using commit id "5437499feb04f7a586f677b155b039bc2b3669eb" and quality "stable" for server
[23:21:30.342] Install and start server if needed
[23:21:30.350] Opening exec server for ssh-remote+test-repo.devpod
[23:21:30.400] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 57750 "test-repo.devpod" bash
[23:21:30.402] Terminal shell path: C:\Windows\System32\cmd.exe
[23:21:30.627] > ssh: Could not resolve hostname test-repo.devpod: Unknown host.
> The process tried to write to a nonexistent pipe.
> ]0;C:\Windows\System32\cmd.exe
[23:21:30.627] Got some output, clearing connection timeout
[23:21:31.887] "install" terminal command done
[23:21:31.887] Install terminal quit with output: ]0;C:\Windows\System32\cmd.exe
[23:21:31.887] Received install output: ]0;C:\Windows\System32\cmd.exe
[23:21:31.888] Failed to parse remote port from server output
[23:21:31.888] Exec server for ssh-remote+test-repo.devpod failed: Error
[23:21:31.888] Existing exec server for ssh-remote+test-repo.devpod errored (Error)
[23:21:31.888] Initizing new exec server for ssh-remote+test-repo.devpod
[23:21:31.888] Using commit id "5437499feb04f7a586f677b155b039bc2b3669eb" and quality "stable" for server
[23:21:31.890] Error opening exec server for ssh-remote+test-repo.devpod: Error
[23:21:31.890] Install and start server if needed
[23:21:31.893] Running script with connection command: "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 57750 "test-repo.devpod" bash
[23:21:31.894] Terminal shell path: C:\Windows\System32\cmd.exe
[23:21:32.359] > ssh: Could not resolve hostname test-repo.devpod: Unknown host.
> The process tried to write to a nonexistent pipe.
> ]0;C:\Windows\System32\cmd.exe
[23:21:32.359] Got some output, clearing connection timeout
[23:21:33.581] "install" terminal command done
[23:21:33.581] Install terminal quit with output: ]0;C:\Windows\System32\cmd.exe
[23:21:33.581] Received install output: ]0;C:\Windows\System32\cmd.exe
[23:21:33.581] Failed to parse remote port from server output
[23:21:33.582] Exec server for ssh-remote+test-repo.devpod failed: Error
[23:21:33.582] Error opening exec server for ssh-remote+test-repo.devpod: Error

Additional info On WSL2 I've only installed devpod cli

Other solution

Maybe you can provide me how can I mount .ssh and gpg files from Windows to ssh host or other solution how can I get .ssh and .gnupg keys?

Windows path problem

Inside devcontainer.json I got this:

"mounts": [
      "source=${env:USERPROFILE}/.ssh,target=/home/dev/.ssh,type=bind,consistency=cached"
    ],

and the problem is:

 info docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /.ssh.
23:W0628 23:33:48.442149    6860 logging.go:59] [core] [Server #1] grpc: Server.processUnaryRPC failed to write status: connection error: desc = "transport is closing"
33:48 info devcontainer up: start dev container: exit status 125

solairen avatar Jun 28 '24 21:06 solairen

Hi @solairen, to me this looks like you're trying to open a container running in WSL2 with VSCode being installed on the windows host. It should work if you install both VSCode and DevPod in WSL2 or both on the Windows host.

DevPod should automatically forward your SSH keys under $HOME/.ssh into the workspace and if you run it with the --gpg-agent-forwarding flag it also forwards your gpg keys.

pascalbreuninger avatar Jul 12 '24 06:07 pascalbreuninger

@solairen: I have a workaround for it:

Create a wsl_ssh.bat file in windows with this content: C:\Windows\system32\wsl.exe --shell-type login ssh %* The shell type login is important to have the right environment variables.

Next in WSL, change the ssh path in the remote-SSH extension settings:

Remote.SSH: Path An absolute path to the SSH executable. When empty, it will use "ssh" on the path or in common install locations.

To: <yout_path>/wsl_ssh.bat

JeanPoll avatar Aug 27 '24 11:08 JeanPoll

@solairen does the fix @JeanPoll provided work for your?

bkneis avatar Oct 17 '24 15:10 bkneis

@bkneis @JeanPoll yes, it helps. Sorry for not closing this issue. Thanks a lot for your help! :)

solairen avatar Oct 17 '24 15:10 solairen

@solairen great glad to hear it!

bkneis avatar Oct 17 '24 15:10 bkneis