Can't connect VS Code to Linux machine for remote development
Solution 1
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
:
Solution 2
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.
Solution 3
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.
Jonatan Aponte
Updated on June 06, 2022Comments
-
Jonatan Aponte almost 2 years
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] ------
-
Julian50 about 4 yearsThank 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
-
clex almost 4 yearsYes, this is true. It is not obvious first time. This comment helped!
-
The Godfather almost 4 yearsIt'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 almost 4 yearsWorks like a charm, awesome, thanks! Especially taking into account that there are no any "dialogs" where you can select it!
-
Maulik Madhavi over 3 yearsThank 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 meSelect the platform of remote host
. The options areLinux/Windows/Mac
. After selection, it worked! -
Maulik Madhavi over 3 yearsThanks boss! however, for the very first time, I need to open VS code with
Run as administrator
mode. -
perlyking over 3 yearsThank 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