VS Code Remote SSH Connection not working - visual-studio-code

Im trying to setup vscode with the remote developement extensions on a second pc. While it works on my main one it doesnt on the second one. Tried reinstalling vscode, extensions and using older versions but nothing works.
When trying to connect it cancels after chosing the os. So I cant even type in the password.
I set it up in the exact same way as with the other pc.
Any ideas?
[20:32:53.595] remote-ssh#0.55.0
[20:32:53.595] win32 x64
[20:32:53.596] SSH Resolver called for "ssh-remote+ssh.blabla", attempt 1
[20:32:53.597] SSH Resolver called for host: ssh.blabla
[20:32:53.597] Setting up SSH remote "ssh.blabla"
[20:32:53.610] Using commit id "58bb7b2331731bf72587010e943852e13e6fd3cf" and quality "stable" for server
[20:32:53.612] Install and start server if needed
[20:32:54.639] Checking ssh with "ssh -V"
[20:32:54.686] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[20:32:54.691] Running script with connection command: ssh -T -D 52819 ssh.blabla bash
[20:32:54.694] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[20:32:54.758] >
]0;C:\WINDOWS\System32\cmd.exe
[20:32:54.758] Got some output, clearing connection timeout
[20:32:54.785] >
[20:32:55.045] > root#blabla's password:
[20:32:55.045] Showing password prompt
[20:32:57.596] "install" terminal command done
[20:32:57.597] Install terminal quit with output: root#blabla's password:
[20:32:57.597] Received install output: root#blabla's password:
[20:32:57.598] Stopped parsing output early. Remaining text: root#blabla's password:
[20:32:57.598] Failed to parse remote port from server output
[20:32:57.603] Resolver error: Error:
at Function.Create (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:1:130564)
at Object.t.handleInstallOutput (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:1:127671)
at I (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:106775)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:104774
at async Object.t.withShowDetailsEvent (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:109845)
at async Object.t.resolve (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:107960)
at async c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:141955
[20:32:57.606] ------
[20:32:59.376] Password dialog canceled
[20:32:59.376] "install" terminal command canceled```

Depending on the system you are in, when you first try to connect, a vscode-server will be set up and configured on your server.
In linux that can be in /Home/<user>/.vscode-server
If you are on windows, check what that is.
The first solution is to try the extension command: Remote-SSH: kill VS Code Server on Host
Open the command pallet (CTRL + SHIFT + P or COMMAND + SHIFT + P (mac) ).
And type Remote kill :
Then try to connect again! (That will kill the server on the host! Which will make it start again on the next try)
If that doesn't work, and things are still failing:
Delete, rm
Then a good solution that can work is: to connect to your server through terminal (vscode terminal, gnome-terminal, whatever). Then go and remove /Home/<user>/.vscode-server
Try to connect after that. At the attempt the server will be re-installed completely anew, chances are it will work. (I did that and it worked for me, so whatever that was going wrong on the vscode-server: just start all over)
But again: you will lose things, config, meta data, etc. (because you start anew).
Update:
As stated by #natevw in the comments:
I found that removing only the .vscode-server/bin subfolder helped straighten things out and afaict kept my data/settings.
Removing only vscode-server/bin seems to work well, and the config, metadata, etc. remains untouched.

I downgrade Remote-SSH plugin to 0.51.0, rm -rf $HOME/.vscode-server on the remote machine. Connect again, VSCode will download and install a new .vscode-server. Then upgrade Remote-SSH plugin, everything works.

One way worked for me is, by adding this line in the vscode settings (JSON) file.
"remote.SSH.useLocalServer": false

I met the same problem. After I did these steps, it works:
on the remote server:
rm -rf ~/.vscode-server
rm -rf ~/.vscode
On the local VS code:
reinstall remote-ssh

In case all the above fails, here's how I fixed my issue.
First, I was able to SSH into my remote server (Ubuntu 22.04, Raspberry Pi 4, arm64) using a simple bash terminal. So I logged in using my terminal (macOS), and I went to
cd $HOME/.vscode-server/bin/WHATEVER-HASH-YOU-HAVE/
In this directory, there is a file named server.sh. I tried running this script, and I got the following error:
./node: error while loading shared libraries: libatomic.so.1: cannot open shared object file: No such file or directory
The issue was clear: there was a missing shared library on my system. Either Node.js now requires that or the new version of the SSH-Remote extension; I don't know. I did not spent the time to dig into those specifics.
But to fix that, I simply did:
sudo apt-get install libatomic1
That installed the missing shared library.
After that, I delete $HOME/.vscode-server:
rm -rf $HOME/.vscode-server
and tried again connecting using VSCode. It worked!
Hope this can help someone like me, for whom all other options failed.

Issue: while trying to ssh connect to Linux(remote machine) using vscode.
Solution: remove/delete the bin folder inside .vscode-server and then reconnect to the remote machine
In remote server:
remote_name:~$ rm -rf ~/.vscode-server/bin
*reconnect to remote machine*

It turns out that my fish was a obstacle for vscode server.
Then I tried
chsh -s /bin/bash
And works fine.

I worked adding \\ in the path of the .config
I share the steps
Go to .config settings
select configuration
add double \\

Just deleted old host information from ssh settings file and problem solved.

I had faced this issue when I tried to connect to a Linux server from a windows laptop.
It was using the wrong fingerprint.
It worked for me after removing the line related to that server from $HOME/.ssh/known_hosts

I ran into the same issue, it got fixed when I updated the path of the IdentityFile from 'ssh_key' to '~/.ssh/ssh_key' (the entire path I mean) so that the VS code could recognize it.

Restart remote machine worked for me (after trying all the previous answers with no luck).

Giving you the oldest trick of the book:
restart
It worked for me and I laughed hysterically for exactly 57 seconds. Happy reconnecting to the server my dear Coder!

I could not connect to the server, my issue was the remote server was full
check with the command df -h if the disk is full !

Here is an alternative for Remote SSH, pls check my answer at: https://stackoverflow.com/a/68046111/13089935
TLDR:
We can use a web-based VS Code that is installed on the server directly.

Related

Disable install of VS Code server

I use my VS Code remote - SSH extension to jump between a lot my customers servers, and would actually like not install the VS Code server on every server that I use.
Is there a way not to install the VS Code server, when you use the Remote - SSH extension, or is there maybe even another extension I should use instead?
To fix this on your own (without using the script mentioned above), you could simply log into each of the linux. cs servers (using SSH), then the command pkill -u node , which will stop any running vscode-server processes
I fixed it but not using the official remote - SSH, but the extension SSH FS, which is a little more combersome as it can see you'r "normal" ssh config, but i works.
https://marketplace.visualstudio.com/items?itemName=Kelvin.vscode-sshfs

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.

Why Connecting with SSH of VS Code I cannot open a specific folder?

I usually connect to remote computers through VS Code SSH. The settings (IP of the remote computer and public and private key pairs are properly set). The strange thing that is happening is that I can open any folder in the remote computer, but not the folder where the project is located (for example, I can also open the parent folder of the project).
It was working properly for years and now it has this type of problem.
Here, I report the output terminal:
[21:03:16.164] "remote.SSH.serverInstallPath": {}
[21:03:16.168] SSH Resolver called for host: PC000
[21:03:16.168] Setting up SSH remote "PC000"
[21:03:16.173] Using commit id "6261075646f044b98968d5000324gdhsdsjdd3b" and quality "stable" for server
[21:03:16.177] Install and start server if needed
[21:03:16.182] Checking ssh with "ssh -V"
[21:03:16.261] > OpenSSH_for_Wind
[21:03:16.262] > ows_8.1p1, LibreSSL 3.0.2
[21:03:16.273] Running script with connection command: ssh -T -D 64484 "PC000" bash
[21:03:16.275] Terminal shell path: C:\Windows\System32\cmd.exe
And after a while, it returns the timeout error.
I am putting the passphrase which it is requesting, then it is not able to connect to the folder.
Do anyone have some ideas?
I tried to open other folders with VS Code SSH connection and they are propery opened. I browsed with the command window to to the folder of the project and everything seem fine.
Did you try this option? "remote.SSH.useLocalServer": false, for more details, you can have a look the discussion here
Setting the terminal.integrated.inheritEnv option to true solved the problem

bash: powershell: command not found

For a node project I will have to work on a remote server and for that I will use filzilla for file transfer and ssh for console.
I use Visual Studio Code, I installed a remote ssh extension,
I did the hostname and user configurations as well as secretkey,
because before that I had another error The process tried to write to a nonexistent pipe ,
which I finally solved but now after I start ssh and log in with the password in cmd from Visual Studio Code, I get this error bash: powershell: command not found.
I tried one day to search the internet for that error.
https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_server_configuration?WT.mc_id=-blog-scottha
https://learn.microsoft.com/en-us/windows/wsl/troubleshooting
I've talked to people who have more experience but within the time limit my advice could be, but I still couldn't solve the error, either it's something from windows or ssh or I don't know.
You are the first time I try to do this in general I used heroku or aws that had some facilities.
I changed host machine in the settings JSON file windows to linux
When you got the option to Select Linux, Windows or Mac did you make sure that you know exactly the type of server you are connecting to. Bcs if you choose the wrong one this error gets thrown.

VScode SSH extension stuck on the installation step

For the past few months, I've used this VSCode Extension to work remotely on a linux server via SSH. I'll occasionally have a connection problem, but sshing from a terminal and deleting ~/.vscode-server/ has always fixed it. This time, though, that didn't fix it. I've tried deleting the folder multiple times, I've removed and reinstalled the VSCode extension, restarting my computer, everything I could think of. But each time, it gets stuck at downloading with wget, even if I leave it going for hours. I can connect to the server by sshing directly just fine, and other people I know can connect to the server through the extension as well. Is there anything else I can try to get this working?
Here's the full installation log (with the host name censored):
[19:17:22.756] Log Level: 2
[19:17:22.758] remote-ssh#0.56.0
[19:17:22.758] win32 x64
[19:17:22.759] SSH Resolver called for "ssh-remote+my.host.name", attempt 1
[19:17:22.759] SSH Resolver called for host: my.host.name
[19:17:22.760] Setting up SSH remote "my.host.name"
[19:17:22.776] Using commit id "e5a624b788d92b8d34d1392e4c4d9789406efe8f" and quality "stable" for server
[19:17:22.777] Install and start server if needed
[19:17:22.800] Checking ssh with "ssh -V"
[19:17:22.831] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[19:17:22.836] Running script with connection command: ssh -T -D 52457 my.host.name bash
[19:17:22.838] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[19:17:22.889] >
>
>
> ]0;C:\WINDOWS\System32\cmd.exe
[19:17:22.889] Got some output, clearing connection timeout
[19:17:22.898] >
>
>
>
[19:17:23.334] > 23b0d284345c: running
>
[19:17:23.363] > Acquiring lock on /path/to/home/.vscode-server/bin/e5a624b78
> 8d92b8d34d1392e4c4d9789406efe8f/vscode-remote-lock.my_username.e5a624b788d92b8d34
> d1392e4c4d9789406efe8f
>
[19:17:23.373] > Installing to /path/to/home/.vscode-server/bin/e5a624b788d92
> b8d34d1392e4c4d9789406efe8f...
> 23b0d284345c%%1%%
>
[19:17:23.381] > Downloading with wget
>
[19:17:27.721] > 23b0d284345c: running
> Acquiring lock on /path/to/home/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/vscode-remote-lock.my_username.e5a624b788d92b8d34d1392e4c4d9789406efe8f
> Installing to /path/to/home/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f...
> 23b0d284345c%%1%%
> Downloading with wget
>
I ended up getting it working. I was connecting to a Centos7 server, what worked for me was deleting ~/.wget-hsts. After that, it reinstalled the server and connected fine.
There are a few reports of a similar issue in the microsoft/vscode-remote-release project which implements for VSCode this feature.
For instance, issue 4008
The remote OS I am connecting to is a RHEL 7 Linux machine.
I tried fiddling with iptables and ports for the wget request to no avail.
It hangs for a little while at the wget step, and ultimately fails to connect. I tried tweaking just about every SSH setting in the remote.
The only other thing I noticed that might be related was with the Ports Available text at the bottom of the screen. It never reads anything other than 0 during the connection process. When I'm properly connected, it says 1 Port Available.
However, I did find a successful workaround: I rolled back the Remote SSH extension to 0.55.0 and it worked like a charm again.
So try and downgrade the Remote SSH extension, to see if it works.
I tried waiting for around 10 minutes and it downloaded. Don't know why although ✨