54

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```
000
  • 651
  • 1
  • 5
  • 6
  • For me deleting the Code folder and restarting the VS Code worked. https://stackoverflow.com/questions/47689536/how-to-completely-uninstall-vs-code-on-windows – trupthi Mar 01 '23 at 09:25

24 Answers24

74

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 :

enter image description here

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.

Mike 'Pomax' Kamermans
  • 49,297
  • 16
  • 112
  • 153
Mohamed Allal
  • 17,920
  • 5
  • 94
  • 97
  • Hi, how do I open this window where I type remote kill please? – Apinorr Sep 26 '21 at 13:14
  • Hi, It's the command pallet. You can do that with CTRL + SHIFT + P (or COMMAND + SHIFT + P in mac) – Mohamed Allal Sep 27 '21 at 09:20
  • That is really helpful. Been searching the solution for days and glad that I pondered on your solution. But may I know why do we have to kill VS code server? – vasu Mar 11 '22 at 01:22
  • 3
    I found that removing only the `.vscode-server/bin` subfolder helped straighten things out and afaict kept my data/settings. – natevw Apr 04 '22 at 16:39
  • Thanks for sharing that. That's great. I'll add a note to the answer. – Mohamed Allal Apr 12 '22 at 13:48
  • I just wanted to add, that I had the same error, but the remote had no vscode-server installed, but rather I had the sync-setting package sync my settings from another computer and I accidently gave the config the same information as on old one so the setting thought it was the wrong OS. Renaming the ssh config fixed everything. – David Folkner Nov 30 '22 at 21:21
  • 1
    rm /Home//.vscode-server worked for me. Thanks – MeiH Jan 05 '23 at 01:41
  • **Solved for me! (on Windows)** I have 2 remote Windows servers, the 1st one was working and the 2nd one stopped working. I had the same SSH logs, it seems that VSCode couldn't copy his server to the 2nd server anymore (I don't know why). I copied the files from the 1st server to the 2nd server: `C:/Users/{myname1}/.vscode-server` from the 1st server to 2nd server `C:/Users/{myname2}/.vscode-server`. Be sure to use the correct SSH user {myname2} to connect to the server after that. – Julha Apr 20 '23 at 09:09
24

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.

ElevenZ
  • 361
  • 1
  • 3
19

One way worked for me is, by adding this line in the vscode settings (JSON) file.

"remote.SSH.useLocalServer": false

VSCode settings

Sreekant Shenoy
  • 1,420
  • 14
  • 23
15

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
benson23
  • 16,369
  • 9
  • 19
  • 38
Creeki
  • 150
  • 1
  • 4
5

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.

ocampeau
  • 157
  • 1
  • 8
4

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* 
2

To add what @cagriyonca mentioned, delete the ip that is in the file located in Windows in:

C:\Users\<YourUsername>\.ssh\known_hosts

This worked for me

  • Thank you sir! I banged my head for hours for not being able to connect to a host I previously connected. – Binar Web May 18 '23 at 11:23
  • I was getting the following errors prior to being prompted for ssh key (or password). Removing `known_hosts` did the trick. "getsockname failed: bad file descriptor" "got some output, clearing connection timeout" "channel_send_open: channel 2: unexpected internal error" "the process tried to write to a nonexistent pipe" – Mike May 19 '23 at 15:41
1

It turns out that my fish was a obstacle for vscode server.

Then I tried

chsh -s /bin/bash

And works fine.

Peg-Noobi
  • 11
  • 1
0

I worked adding \\ in the path of the .config

I share the steps

  • Go to .config settings

  • select configuration

  • add double \\

Andres Aya
  • 74
  • 4
0

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

0

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

0

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.

0

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

Jack
  • 1
0

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!

0

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 !

cogis
  • 21
  • 3
0

In my case I needed to remove arm_64bit=1 from config.txt (/boot/config.txt).

Mário Prada
  • 1,792
  • 1
  • 9
  • 13
0

I had previously tried to get vs code working on the remote machine. I deleted both the home/.vscode-server AND the .vscode directories. These dirs were NOT deleted by uninstalling vs code on the remote machine

This also might help. I set the debug level by adding "logLevel DEBUG3" on the .ssh config file in VSCode

The logs are were very hard for me to find and are not named as the terminal output says they are (long hex string .log). I finally found it them in C:\Users<user>\AppData\Roaming\Code\logs they can be found by using command Developer:Open logs folder. There you will find subfolders named windowx. Under the window where the error occurred (you just have to look in by time) find exthot/output_logging_xxxxx/remote - ssh.log.

Charles Bisbee
  • 357
  • 1
  • 4
  • 10
0

I tried below steps in host terminal and issue was resolved.

cd .vscode-server/bin/

cd b3e4e68a0bc097f0ae7907b217c1119af9e03435/ (this folder name can be different for you)

tar -zxvf vscode-server.tar.gz

mv vscode-server-linux-x64/* .

rm -rf vscode-server-linux-x64/ vscode-server.tar.gz

touch 0

meupul
  • 65
  • 5
0

In my situation i tried all other answers that were given in this thread, None worked. I could manually ssh through the command line but I could not connect through Connect to Host... option.

My solution was to connect to the VPN of my company (since this is a work related topic)

  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/34481067) – Wahlstrommm Jun 07 '23 at 11:41
0

In my case (Rocky9 minimal install) the "tar" utility was not installed. After I installed tar (dnf install tar) it starts working. The error message produces by installer is quite misleading.

Karlik_B
  • 189
  • 2
  • 2
  • 11
0

For me, turned out it was a issue with the .pem file

After testing all solutions above, I figured out the .shh/config file was using IdentityFile without the complete path. So, I added the complete path on the config file such as:

Host your-alias
  HostName ec2-xx-yy-zz.compute-1.amazonaws.com
  IdentityFile C:\Users\your-user\folder\ec2-pem-file.pem
  User ubuntu

When prompting the error "Could not establish connection", I checked on the log (VS Code Output tab) the "no such identity" message just before the "[20:32:57.603] Resolver error: Error: " message.

0

The previous answers may not be sufficient if your SSH host server lacks SSD capacity.

If you have tried all the above solutions and they have not worked for you, check if your host server has enough capacity to accommodate ./vscode-server. In my case, after deleting large files from my server, I was able to effectively use SSH.

greybeard
  • 2,249
  • 8
  • 30
  • 66
JERMY
  • 1
  • 1
0

For me the issue was that ~/.bashrc on my remote server contained an erroneous 'exit' that was supposed to execute only during non-interactive sessions, to avoid terminal output during scp commands.

I had implemented that solution successfully on another server though. Not sure why it broke the second one. Both are CentOS 7, but different patch levels.

Removed the exit statement and now remote-ssh works great.

# .bashrc
# ...
if [[ $- == *i* ]]
then
    :
else
    exit # <--- Culprit
fi
# Other stuff useful only for interactive shells.

I had found this solution here: https://unix.stackexchange.com/questions/26676/how-to-check-if-a-shell-is-login-interactive-batch but now starting to doubt it?

-1

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.

AverageGod
  • 95
  • 1
  • 6