22

I am getting this error on VS Code and have no clue why it fails

[15:14:59.543] Log Level: 2
[15:14:59.555] remote-ssh@0.51.0
[15:14:59.555] win32 x64
[15:14:59.560] SSH Resolver called for "ssh-remote+xx.xx.xx.xx", attempt 1
[15:14:59.561] SSH Resolver called for host: xx.xx.xx.xx
[15:14:59.561] Setting up SSH remote "xx.xx.xx.xx"
[15:14:59.621] Using commit id "0ba0ca52957102ca3527cf479571617f0de6ed50" and quality "stable" for server
[15:14:59.624] Install and start server if needed
[15:15:01.964] getPlatformForHost was canceled
[15:15:01.965] Resolver error: Connecting was canceled
[15:15:01.973] ------
halfer
  • 19,824
  • 17
  • 99
  • 186
Jonatan Aponte
  • 429
  • 1
  • 5
  • 10

5 Answers5

21

Add one key in your settings.json as below. Please remember to replace the $remote_server_name to yours.

    "remote.SSH.remotePlatform": {
        "$remote_server_name": "linux"
    }

Menu: File->Preference->Settings

Or click the icon to open settings.json:

The Godfather
  • 4,235
  • 4
  • 39
  • 61
grit
  • 211
  • 1
  • 2
  • Works like a charm, awesome, thanks! Especially taking into account that there are no any "dialogs" where you can select it! – The Godfather Jul 28 '20 at 06:51
  • 2
    Thank you boss! I could not edit the settings.json when vscode is opened with non-admin rights. However, I tried using `Run as Administrator`, it worked, it asked me `Select the platform of remote host`. The options are `Linux/Windows/Mac`. After selection, it worked! – Maulik Madhavi Nov 21 '20 at 01:12
9

In dialog box where you have typed user@host type/select Linux/Windows/etc. depends what you are using, then type/select Continue, then type password for remote session.

imperato
  • 329
  • 2
  • 12
  • 3
    Thank you. First time is not obvious that in the top of the new window, you have select OS target then type the password on the bottom windows – Julian50 Apr 08 '20 at 13:25
  • Yes, this is true. It is not obvious first time. This comment helped! – clex May 18 '20 at 17:26
  • 1
    It's not clear where you can select OS, there is nothing in the command line where you type "Connect to host". @grit's answer is more useful – The Godfather Jul 28 '20 at 06:50
  • 1
    Thanks boss! however, for the very first time, I need to open VS code with `Run as administrator` mode. – Maulik Madhavi Nov 21 '20 at 01:13
2

For those getting this error on Windows: Check if you have multiple ssh clients installed.

How I solved it was by adding my ssh-configuration to ALL ssh-config files. In my case I had one in

  • C:\Users\USER_NAME.ssh\config (this is the one that the remote extension used to give me connection options)
  • and another in C:\Program Data\ssh\ssh-config

After adding my ssh-config setting to both I got the prompt to select virtual hosts' OS. Tried editing the settings.json file directly, but I think it gets confused because of the multiple ssh-configurations.

P.S.

Tested it for both private key and password enabled connections and it work with either.

Misho Janev
  • 512
  • 5
  • 13
  • Thank you; this gave me the pointer I needed. As well as the two config file locations you mention, having Cygwin installed, I also had to edit ~/.ssh/config from the Cygwin shell. Turns out this was the SSH that VS was using. Remember to convert the IdentityFile path to one that uses /cygdrive/.../path/to/private_key – perlyking Dec 07 '20 at 22:26
0

I got a similar problem, but the error logs were bigger. Before that, I deleted the python and reinstalled it. Perhaps this led to the problem. Just reinstalled "Remote -SSH" extension in vscode and it worked for me.

0

In my case there were two files that look like

vscode-remote-lock.<user>.<xxx> vscode-remote-lock.<user>.<xxx>.target

where was my remote user name and xxx the VS Code Remote Server build hash.

These two files on the remote server in the folder.

/run/user/1000/

I deleted both files and then VS Code came up right away. I have encountered this a few times now. VS Code Remote Server install is not very robust. I use it on about 7 remote machines and every once in a while something goes awry and it cannot recover from simple errors and gets stuck in installation loops.

This trick only works if there is a valid ~/.vscode-server on the remote machine with a hash that matches your local VS Code installation.

If you got here because you were trying to install VS Code in the first place and for whatever reason VS Code had issues with the remote installation, I highly recommend installing it manually by downloading and extracting the tar file to the remote machine directly.

I have tried playing with the setting "Use remote.SSH: Use Flock" and other tricks posted on StackOverflow but none of these work for me whenever I have remote installation issues. I cannot figure out why on some machines, a smooth remote installation is not possible. Even when all of my ssh keys and remote ids have been copied and tested from both the Windows command line and inside a WSL Ubuntu instance.

If VS Code Remote Server installation had slightly better error logic and better error messages none of us would be wasting hours doing this simple task.

I was getting the exact same error as the original poster received and yet none of the other answers were my issue.

ejkitchen
  • 559
  • 6
  • 11