-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote-SSH: Fails to discover WSL SSH #937
Comments
@roblourens Did the update to dynamically find the SSH client on Windows include a WSL check or did that get cut/missed? |
Yeah I missed that entirely. Can you suggest how I should discover/invoke WSL ssh? Also would have to figure out how config files will work. WSL ssh would not look at windows' ssh config files by default and vice versa. |
Enabling the WSL ssh would be awesome, since it should make it possible to take advantage of |
@roblourens I've got a PR out to update docs in the mean time. You should be able to detect WSL SSH with the following command line call:
Non-zero exit means it's not there. |
Thanks for jumping onto this one guys, saves us having to run two SSH configurations. |
Additional test case as this is implemented...
I tried three alternate settings.json of "remote.SSH.path": "C:\\Windows\\System32\\wsl.exe ssh"
"remote.SSH.path": "\\\\wsl$\\Ubuntu-18.04\\usr\\bin\\ssh"
"remote.SSH.path": "/usr/bin/ssh" They all failed with the
I have a very little tested workaround to force WSL ssh. Use a settings.json of "remote.SSH.path": "c:/njs/ssh.bat" with an ssh.bat of @echo off
set v_params=%*
set v_params=%v_params:\=/%
set v_params=%v_params:c:=/mnt/c%
REM set v_params=%v_params:"=\"%
C:\Windows\system32\wsl.exe ssh %v_params% |
Hello. A regression in use of the setting The setting SetupVersion: 1.37.0 (system setup) Repo
ResultThe connection fails. In the Remote SSH output window is the error
ExpectedNo error and a successful connection WorkaroundChange the setting of the path to use backslashes
|
Ugh windows. Forked that into #1148, thanks. |
I can attest that using ssh through wsl would be amazing. Apart from the obvious non-duplication of configs, I need to connect to a host which only allows kerberos authentication. Is there a documented workaround for now? I tried the ssh.bat file hack mentioned above, but got nowhere. There's an error stating The specified path is not a valid SSH binary |
Setting |
Seems like this one's a doozy, everyone's efforts are appreciated. |
My previous solution to this broke today. I had to change
to
otherwise I would get the error:
Playing around in PowerShell, it looks like a change in how WSL launches commands. The other annoying change is that VSCode is not populating the hosts list from my WSL .ssh/config. By default it grabs the copy I have in C:\Users....ssh, if I hard code the WSL path as I've done in the past, the list is blank. Removing the windows copy does not force it to look for the WSL copy. With the config path blank, and the list populated by the windows config file, I can launch remote connections with no issues, BUT, it's using the settings from the WSL config file! |
For those coming now to this I tried a lot of the solutions above the one that worked was the Make the file
Change your
Everything then works through the config in your wsls ssh config. |
For those suddenly having issues with vsc no longer loading the wsl ssh config file. Beginning with VS Code 1.78.1, accessing any UNC path (those that begin with \\) is blocked to mitigate a security risk that is covered in this Security Advisory. This can be fixed by adding the following to your settings.json and then restarting vsc. "security.allowedUNCHosts": ["wsl$", "wsl.localhost"], |
In my case I had to add "wsl.localhost" instead of "wsl$" Thanks! |
Ahh good point @sXe79. Yes, 'wsl.localhost' is sometimes used instead of 'wsl$'. I have updated my comment to include that. |
Update on my problem. As of 09.01.23, ver. 1.81.1 everything works just fine if I leave |
I really cannot get this to work. I just want to connect from my WSL2 instance to my home server using my WSL2 ssh and config file
What should I paste into EDIT "security.allowedUNCHosts": ["wsl$"],
"remote.SSH.path": "\\\\wsl$\\Ubuntu\\usr\\bin\\ssh",
"remote.SSH.configFile": "\\\\wsl$\\Ubuntu\\home\\einar\\.ssh\\config",
"remote.SSH.showLoginTerminal": true, With this VSCode detects the config file, since I can see hosts that I have added to the config file. However, the usage of the config file fails since it looks for the identity file relative to the windows file system (I see this briefly in an error which disappears quickly) |
this approach still works fine #937 (comment) |
So what is the value of I have tried this now and leaving it unset does not work for me. Neither does setting it to Please share a EDIT Thanks! (would be great with official support though...) |
I'm having this issue again in 1.83.1. I use the solution from #937 and it worked fine in the past but now does not. I have tried the allowedUNCHosts but remote-ssh does not find wsl |
I'm been having this issue persist since maybe July. I've tried most of the fixes in the thread but nothing seems to fix the ability to actually use the SSH config file. The |
If the error in the console is |
I've found that the prescription in #937 (comment) still works. However, I have a wrapper (passing appropriate bitwarden password) of the |
This configuration works for me (Version: 1.84.2)
|
I have tried several times over the past couple years to get this to work always hoping it will, and always being disappointed. I'm amazed that so many of you find it to be functional. I tried adding the bat file in my home directory that runs wsl ssh.exe %*. When I try to login, it asks me for a password. It may or may not accept the input. If it asks me ANY follow up questions (accept this key?), it will DEFINITELY not accept that input. I tried adding "remote.SSH.showLoginTerminal": true, but I can't type in there either. If I use controlmaster (which is the whole point) and connect to my server first from wsl, I get a new error about "dynamic port forwarding fails". The command ran, and it looks good to me. I use curl as a socks proxy with the dynamic port it opened and it's working JUST fine. So is VScode looking for the port on the local windows host? That wouldn't work, but that would explain why it clearly set things up, but nothing works. Do none of you experience these problems? I don't think I'm doing anything unusual here. I want ControlMaster and ProxyJump because my work requires a bastion host. |
I just install "Git for Windows" and wait for the day the devs work out this feature and I can stop installing it. |
@UnicodeTreason Can you share your setting.?
same here..gave up! ;( |
Same here. After so many times trying and always being disappointed when dealing with complex ssh configs like proxyjump or remote command, I find the best way for it is to use vscode in WSL GUI. |
@devd79 No special settings, VSCode just uses the SSH that "Git for Windows" installs according to the doc. Though I just checked and it seems my VSCode is now using the SSH that PowerShell uses (No idea if its vanilla or my desktop SOE team are legens). Guess I swapped to using it a while back and forgot about it. [15:11:38.761] Checking ssh with "C:\WINDOWS\system32\ssh.exe -V"
[15:11:38.766] Got error from ssh: spawn C:\WINDOWS\system32\ssh.exe ENOENT
[15:11:38.767] Checking ssh with "C:\WINDOWS\ssh.exe -V"
[15:11:38.768] Got error from ssh: spawn C:\WINDOWS\ssh.exe ENOENT
[15:11:38.769] Checking ssh with "C:\WINDOWS\System32\Wbem\ssh.exe -V"
[15:11:38.770] Got error from ssh: spawn C:\WINDOWS\System32\Wbem\ssh.exe ENOENT
[15:11:38.770] Checking ssh with "C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe -V"
[15:11:38.772] Got error from ssh: spawn C:\WINDOWS\System32\WindowsPowerShell\v1.0\ssh.exe ENOENT
[15:11:38.772] Checking ssh with "C:\WINDOWS\System32\OpenSSH\ssh.exe -V"
[15:11:38.823] > OpenSSH_for_Window
[15:11:38.823] > s_8.1p1, LibreSSL 3.0.2 The REAL pain is having more than one .ssh dir floating around. |
@Raibows I didn't notice your response, but I came to the same conclusion today -- running the linux version from WSLg. Spent some time testing and it seems to work perfectly. I even got usbipd working so I can pass thru my smart card reader and connect to the jump hosts that need that. |
Update 2024-04-22:
|
@mahmoud-samy I don't know why you posted this. It's almost exactly what's already been posted in this thread, except you left out some important stuff like setting VS Code to use that batch file for the ssh path, and the most important detail, that THIS DOES NOT WORK. I would love to be proven wrong, btw. I would love to see a video demonstrating the entire process from start to finish. Create the batch file, set up VS code remote SSH path, open a connection to a remote SSH server, and open a workspace on that remote server from the terminal. I've been trying on and off for at least 2 years to get WSL SSH to work with Windows VS Code, and it's never worked even once. The batch file idea LOOKS promising. It did connect to a remote server for me ONE time, but I couldn't open a workspace afterwards, so even that was useless. It never would connect to the server again -- no idea why it worked the first time. After using the wslg Linux version for a couple weeks, I find it works pretty well, though wslg seems to crash sometimes with my windows freezing up and being totally unresponsive. I have to use wsl.exe --shutdown and restart things. But it hasn't happened often enough to get me to abandon it, but if I could get WSL ssh working with VS code windows, I would totally do that. TLDR; Microsoft is never going to fix this. Whatever reason any of us have for wanting to use WSL ssh is not important enough to dedicate developer resources towards. wslg is a realistic (if imperfect) solution. If you need a fully functional OpenSSH client, don't use Windows. |
I have been able to use @ltalirz 's teknik here: #937 (comment)
having said that my setup is not a 100 percent on UX or simply said is not fully refined as a few screws need tightening up, and this could be the fourth point for observation to the above,
FUTURE WORK:-
tested on : vscode 1.89.1 on my windows 11 machine, where I am running wsl ubuntu-22-04. |
I was struggling with the ssh.bat method, and kept getting prompted for the (wsl) ssh key passphrase until I realised it was using the default bash shell even after I used chsh to set my shell to zsh. Updating ssh.bat to the following fixed it for me :
|
Steps to Reproduce:
Got error from ssh: spawn ssh ENOENT
Testing ssh with C:\WINDOWS\System32\OpenSSH\ssh.exe -V
Got error from ssh: spawn C:\WINDOWS\System32\OpenSSH\ssh.exe ENOENT
Testing ssh with C:\Program Files\Git\usr\bin\ssh.exe -V
Got error from ssh: spawn C:\Program Files\Git\usr\bin\ssh.exe ENOENT
Testing ssh with C:\Program Files (x86)\Git\usr\bin\ssh.exe -V
Got error from ssh: spawn C:\Program Files (x86)\Git\usr\bin\ssh.exe ENOENT
Finding installed ssh failed: ssh installation not found
ssh installation not found
Which is unexpected as the documentation here: https://code.visualstudio.com/docs/remote/troubleshooting#_installing-a-supported-ssh-client
Specifically states it'll use WSL SSH
These closed issues also make it look as though it WAS added recently:
#359
#448
The text was updated successfully, but these errors were encountered: