Visual Studio Code Remote SSH on Windows and (Remote) Linux

Update: Scroll down for final(ly the) solution!

Visual Studio Code has a pretty neat feature called Remote SSH  that eases code development on a remote machine. From outside, the extension looks similar to an IDE running on a host machine. Only difference is that files shown are of remote machine’s and any updates are reflected on the remote machine. Remote SSH extension comes bundled with Visual Studio (at least for 1.39).


Although it sounds spectacular in theory, I had a couple of problems while trying to connect to a remote Linux machine on a Windows machine. I will detail some of the problems I faced and their solutions.

SSH Config Errors : Conflicting Usernames, Obviously Wrong HostName

It is possible to set up a SSH config file to connect to a remote machine. The config file can be updated with F1 > Remote-SSH: Open Configuration File. A simple file looks like this:

 Host <host_identifier>
    User <user_name>
    HostName <host_name>

I’ve had two nasty problems with this file:

  1. Unfortunately, VS Code 1.39 on my Windows PC tries to parse this file as though the <host_identifier> is the <host_name>. In result, ssh resolver fails miserably. Updating the <host_identifier> as the <host_name> results in connection error *due to some reason (see below)*.
  2. Instead of using <user_name> on the remote machine, VS Code uses my current username on the host machine, which if they are different, will result in despair.

The biggest issue with these two problems are that ***it is not clear why they happen***. Here are some logs:

 [21:26:02.497] remote-ssh@0.47.2
[21:26:02.497] win32 x64
[21:26:02.498] SSH Resolver called for "ssh-remote+<host_identifier>", attempt 1
[21:26:02.498] SSH Resolver called for host:  <host_identifier> 
[21:26:02.498] Setting up SSH remote " <host_identifier>"
[21:26:02.561] Using commit id "6ab598523be7a800d7f3eb4d92d7ab9a66069390" and quality "stable" for server
[21:26:02.562] Testing ssh with ssh -V
[21:26:02.685] ssh exited with code: 0
[21:26:02.685] Got stderr from ssh: OpenSSH_5.4p1, OpenSSL 1.0.0 29 Mar 2010
[21:26:02.695] Running script with connection command: ssh -T -D 50193 <host_identifier> bash
[21:26:02.698] Install and start server if needed
[21:26:02.699] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[21:26:03.004] > 
[21:26:03.004] Got some output, clearing connection timeout
[21:26:03.324] > <host_username>@<host_identifier> 's password:
[21:26:03.324] Showing password prompt
[21:26:05.779] Password dialog canceled
[21:26:05.779] "install" terminal command canceled
[21:26:05.779] Resolver error: Connecting was canceled
[21:26:05.781] TELEMETRY: {"eventName":"resolver","properties":{"outcome":"failure","reason":"Canceled","askedPw":"1","askedPassphrase":"0","asked2fa":"0","askedHostKey":"0","gotUnrecognizedPrompt":"0","remoteInConfigFile":"1"},"measures":{"resolveAttempts":1,"retries":1}}
[21:26:05.781] ------


How to Solve (well… Work around)

  1. In Visual Studio Code Settings, search for conpty. Uncheck its use. Initially suggested here
  2. Create a user on the remote machine with the host username (a workaround as promised). If you want to make changes on the actual user’s home directory, update access control rules to allow writes by the newly created user:
setfacl -R -m u:<host_username>:rwx <remote_user_folder> # -R for recursive

Final Solution

Update the Remote.SSH Config File settings (accessible via Remote Explorer > Settings (Gear Icon) > Settings) to specify the location for the SSH Config file to be used. Previously used config file that causes the errors above should work now!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close