Jonatan Aponte
Jonatan Aponte

Reputation: 479

Can't connect VS Code to Linux machine for remote development

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] [email protected]
[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] ------

Upvotes: 24

Views: 26015

Answers (5)

ejkitchen
ejkitchen

Reputation: 599

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.

Upvotes: 0

Kaisar Barlybay
Kaisar Barlybay

Reputation: 21

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.

Upvotes: -1

Misho Janev
Misho Janev

Reputation: 532

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.

Upvotes: 2

grit
grit

Reputation: 221

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:

Upvotes: 22

imperato
imperato

Reputation: 329

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.

Upvotes: 9

Related Questions