[VsCode Remote SSH]How to solve 'Could not establish connection to XXX.XXX.XXX.XXX: Downloading VS Code Server failed'? - visual-studio-code

[Problem Description]
When I work on setting VS Code remote ssh on a new server, I find this error:
"Could not establish connection to "XXX.XXX.XXX.XXX":Downloading VS Code Server failed - please install either curl or wget on the remote".
However, I have curl and wget installed on my remote server. And the network connection on my remote server is also fine. Following some tutorials in the web, I download vscode-server on the remote side by:
wget vscode-server-linux-x64.tar.gz https://update.code.visualstudio.com/commit:<commit-id>/server-linux-x64/stable
and then extract it, copy to ~/.vscode-server/bin/<commit-id>/, and replaced the files there.The error message disappears.
It works fine at the beginning, but everytime I close and reopen project on the remote server, VsCode would start to download remote server automatically and then collapse to so called "please install either curl or wget on the remote". Moreover, the VsCode built-in terminal would fail to no cuda environement or GPU driver error(Cuda and driver work fine on remote side) even if I fortunately connect to remote at chance.
[Environment]
Local Side:
MacOS Big Sur 11.2.3 + VsCode 1.50.1 + Remote-SSH Extension(Microsoft) 0.6.1
Remote Side
Ubuntu 18.04.5 + Wget 1.19.4 + Curl 7.58.0
[Log]
[10:57:03.119] Neither curl nor wget is installed - can't download the Server
[10:57:03.125] Resolver error: Error: Downloading VS Code Server failed - please install either curl or wget on the remote.
at Function.ServerInstallError (/Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:1:82253)
at /Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:1:79401
at Object.t.handleInstallOutput (/Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:1:80935)
at I (/Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:127:107056)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async /Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:127:104971
at async Object.t.withShowDetailsEvent (/Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:127:110308)
at async Object.t.resolve (/Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:127:108372)
at async /Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:127:129627
[10:57:03.131] ------
[10:57:03.428] "install" terminal command done
[10:57:03.429] Install terminal quit with output:

This may be because there are so many vscodes open on the remote server that you need to kill all the VSCODE processes on the remote server and then try to connect again or make a new connection, save host information.

Related

VS Code Remote-SSH won't reconnect to one specific working directory on remote Ubuntu host

I'm using VSCode 1.72.2 with Remote-SSH v0.90.1 on Windows to develop against an AWS EC2 VM running Ubuntu 22.04 LTS. A couple days ago, I was working in my project source folder in /opt/t4/ on the target host. When I was finished, I stopped the VM from the AWS console, forgetting that VS Code was still SSHed in.
When I brought the VM back up, I can reconnect VS Code/Remote-SSH to the host as before, except that I can no longer connect using /opt/t4/ as my working directory. I can use any directory except the one I was using when I disconnected.
I can navigate down to it and work in it if I use /opt/ as my working directory. I can navigate to it by manually SSHing to the remote host. I can create a subfolder in a remote shell at /opt/t4/test/, and then connect VS Code using that subfolder as my working directory. I can see and select /opt/t4/ in the Open Folder dialog in VS Code. But when I try to connect using that working directory, the connection times out with a not-particularly-useful error message:
[00:05:49.867] SSH Resolver called for "ssh-remote+my.remote.host", attempt 2, (Reconnection)
[00:05:49.868] SSH Resolver called for host: my.remote.host
[00:05:49.868] Setting up SSH remote "my.remote.host"
[00:05:49.870] Using commit id "d045a5eda657f4d7b676dedbfa7aab8207f8a075" and quality "stable" for server
[00:05:49.872] Install and start server if needed
[00:05:49.874] Using SSH config file "C:\Users\me\.ssh\config"
[00:05:49.874] Running script with connection command: ssh -T -D 1518 -F "C:\Users\me\.ssh\config" "my.remote.host" bash
[00:05:49.875] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[00:06:06.876] Resolver error: Error: Connecting with SSH timed out
at g.Timeout (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.90.1\out\extension.js:1:585348)
at Timeout._onTimeout (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.90.1\out\extension.js:1:679743)
at listOnTimeout (node:internal/timers:559:17)
at process.processTimers (node:internal/timers:502:7)
[00:06:06.877] ------
I tried Remote-SSH: Uninstall VS Code Server from Host from VS Code.
I tried deleting ~/.vscode-server on the Linux host from an SSH session.
I tried Remote-SSH: Kill VS Code Server on Host from VS Code.
I tried Remote-SSH: Kill Local Connection Server for Host from VS Code.
I tried deleting and recreating the host connection details in the local config file from SSH-Remote.
I tried rebooting both local and target hosts.
I tried setting /opt/ as my working dir, then deleting and recreating /opt/t4. I was able to do this, but as soon as I try reconnecting using /opt/t4 as the working dir, VS Code still fails to connect.
I'm... stumped. My suspicion is that there is something corrupt cached Windows-side, but I don't know where to look for that.
Microsoft is aware and working on a fix. There are a variety of workarounds in this thread: https://github.com/microsoft/vscode-remote-release/issues/7324
Thanks to the link from #Mike Barry, I managed to find the local workspace for that target folder and delete it to force it to reinitialize, which cleared the issue.
Deleted C:\Users\me\AppData\Roaming\Code\User\workspaceStorage\[guid]\ and reconnected with no problem.

vscode remote ssh connection cannot connect on windows server 2022

I'm trying to setup Remote SSH extension on vscode to connect to a server that runs Windows Server 2022.
First, I can connect with SSH from the terminal ssh username#public_ip -p port then I enter the password and I can access the server.
I installed the Remote - SSH extension on vscode. I was able to connect to a Raspberry Pi without problems... But I cannot connect to a Windows Server 2022.
It asks me to enter the username password twice, then after a few seconds it stops with two errors pop-ups (see picture below).
Could not fetch remote environment
Failed to connect to the remote extension host server (Error: WebSocket close with status code 1006)
errors
Also, from another machine. I can connect to my server with vscode and the same extension (Windows Server 2022) without any problems so I don't think that the server has any issues. Seems like the problem is on my computer that won't connect.
I was able to connect once but I did break something and I don't know what. I tried to reinstall the extension but nothing helped.
EDIT:
I think I fixed it.
Here's what I did.
I uninstalled the Remote - SSH extension
I opened the settings.json on my local computer and deleted everything that had to do with this extension.
Deleted the config file from C:\Users\username\.ssh\config
I restarted vscode
Installed the extension
And it worked.

How to stop reinstalling VS Code Server over SSH

I installed Remote - SSH extension for VS Code 9v 1.63.2) on Windows 10. I successfully connect to a linux remote machine and can edit my files remotely over the SSH server. But for some reason every time I boot up this project, it deletes, redownloads, and re-installs the server. This takes a while with my internet connection. Anyway to force it to re-use the existing install?
A sample log:
Acquiring lock on /home/myuser/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/vscode-remote-lock.myuser.899d46d82c4c95423fb7e10e68eba52050e30ba3
Found old VS Code install f4af3cbf5a99787542e2a30fe1fd37cd644cc31f, attempting to clean up
Deleting old install from /home/myuser/.vscode-server/bin/f4af3cbf5a99787542e2a30fe1fd37cd644cc31f
rm: cannot remove '/home/myuser/.vscode-server/bin/f4af3cbf5a99787542e2a30fe1fd37cd644cc31f': Directory not empty
Deleting old log file from /home/rmchh/.vscode-server/.f4af3cbf5a99787542e2a30fe1fd37cd644cc31f.log
Installing to /home/myuser/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3...
172891dd6284%%1%%
Downloading with wget
wget download failed
https://update.code.visualstudio.com/commit:899d46d82c4c95423fb7e10e68eba52050e30ba3/server-linux-x64/stable: 2021-12-17 03:44:39 ERROR 503: Service Unavailable.
printenv:
PWD=/home/myuser/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3
...

How can i ssh with VScode 1.53.2 to an Ubuntu 14.04 VM server

Using VS code to ssh into an Ubuntu 14.04 server. At first i couldn't even connect, but after installing git for windows after putting password i get: Could not establish connection to "Host name".
I can ssh into this server with putty or powershell.
This is the output on VS code:
[13:55:01.574] Got password response
[13:55:01.575] "install" wrote data to terminal: "********************"
[13:55:01.605] >
>
[13:55:04.040] "install" terminal command done
[13:55:04.040] Install terminal quit with output:
[13:55:04.040] Received install output:
[13:55:04.041] Stopped parsing output early. Remaining text:
[13:55:04.041] Failed to parse remote port from server output
[13:55:04.048] Resolver error: Error:
at Function.Create (c:\Users\Turro\.vscode\extensions\ms-vscode-remote.remote-ssh-0.64.0\out\extension.js:1:64126)
at Object.t.handleInstallOutput (c:\Users\Turro\.vscode\extensions\ms-vscode-remote.remote-ssh-0.64.0\out\extension.js:1:62865)
at k (c:\Users\Turro\.vscode\extensions\ms-vscode-remote.remote-ssh-0.64.0\out\extension.js:1:313462)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async c:\Users\Turro\.vscode\extensions\ms-vscode-remote.remote-ssh-0.64.0\out\extension.js:1:311339
at async Object.t.withShowDetailsEvent (c:\Users\Turro\.vscode\extensions\ms-vscode-remote.remote-ssh-0.64.0\out\extension.js:1:406337)
at async Object.t.resolve (c:\Users\Turro\.vscode\extensions\ms-vscode-remote.remote-ssh-0.64.0\out\extension.js:1:315001)
at async c:\Users\Turro\.vscode\extensions\ms-vscode-remote.remote-ssh-0.64.0\out\extension.js:127:110431
[13:55:04.054] ------
Thanks in advance, ill be glad to pass any more information required to solve this problem!
I can ssh into this server with putty or powershell.
That could mean you are using an SSH key with putty ppk format instead of OpenSSH.
Try and launch VSCode from a session where:
the %PATH% does not reference Putty (but does include Git, and its usr/bin folder)
the GIT_SSH environment variable is set to ssh (although it should not be needed, if the PATH is correctly set)

Remote editing over ssh to windows server

Remote SSH plugin states VS Code Insiders has experimental support for Windows 10/Server 1803+ using the official OpenSSH server.
I have the official OpenSSH server installed and configured on Windows Server 2019 1809. I can connect via pubkey authentication and have PowerShell Core over ssh working as well. I tried both Remote SSH and Remote SSH nightly plugin. At first it was complaining that it couldn't find bash. So I installed git bash and added it to the system path. I get the following error when attempting to connect to my windows server:
[16:02:41.398] Log Level: 3
[16:02:41.399] remote-ssh-nightly#2019.12.24000
[16:02:41.399] darwin x64
[16:02:41.401] SSH Resolver called for "ssh-remote+myserver", attempt 1
[16:02:41.401] SSH Resolver called for host: myserver
[16:02:41.401] Setting up SSH remote "myserver"
[16:02:41.413] Using commit id "e74405d11443c5361c31e2bc341866d146eee206" and quality "insider" for server
[16:02:41.414] Testing ssh with ssh -V
[16:02:41.425] ssh exited with code: 0
[16:02:41.425] Got stderr from ssh: OpenSSH_7.9p1, LibreSSL 2.7.3
[16:02:41.430] Running script with connection command: ssh -T -D 51951 -o ConnectTimeout=15 myserver bash
[16:02:41.430] Install and start server if needed
[16:02:43.451] > 5122b1a5b835: running
> Unsupported architecture: MINGW64_NT-10.0-17763 x86_64
> 5122b1a5b835##27##
[16:02:43.452] Got some output, clearing connection timeout
[16:02:43.710] "install" terminal command done
[16:02:43.710] Install terminal quit with output: 5122b1a5b835##27##
[16:02:43.710] Received install output: 5122b1a5b835##27##
[16:02:43.710] Unsupported architecture
[16:02:43.711] Resolver error: The remote host's architecture is not supported
[16:02:43.714] ------
Anybody know the magic sauce to get Remote SSH working w/ Windows 10/Server?
Looks like VSCode is attempting to run bash on the server which I'm guessing would resolve to git's bash which is mingw based as I recall. VSCode should be running Powershell on the server.
Did you include your server in the list of windows remotes in the extension's settings?
Requires "remote.SSH.windowsRemotes" setting. Here is the documentation.
"remote.SSH.windowsRemotes": ["myserver"]