5
votes

I am trying to connect from my Windows 10 machine to my Ubuntu Linux server (16.04.6) using Remote SSH. To do this I've read many different tutorials but have no success.

I am able to connect from my Windows 10 command prompt to the Ubuntu Linux server via ssh without any problems. I even used ssh-keygen to generate a private and a public key and copied the public key to the appropriate directory on the Linux Server (.ssh).

In VsCode I installed the extension Remote-SSH added my host to my configuration file c:\user.ssh\config:

Host <ip-address>
  HostName <ip-address>
  User <username>

Then I clicked in VSCode the button bottom left "Open a remote Window" and chosed my host. A new windows opens and VSCode is trying to connect. Then I see a window with the error message: "Could not establish connection to . Connection was canceled". This is the log.

[11:53:17.573] Log Level: 2
[11:53:17.582] [email protected]
[11:53:17.583] win32 x64
[11:53:17.586] SSH Resolver called for "ssh-remote+<ip-address>", attempt 1
[11:53:17.587] SSH Resolver called for host: <ip-address>
[11:53:17.587] Setting up SSH remote "<ip-address>"
[11:53:17.648] Using commit id "5763d909d5f12fe19f215cbfdd29a91c0fa9208a" and quality "stable" for server
[11:53:17.650] Install and start server if needed
[11:53:18.624] getPlatformForHost was canceled
[11:53:18.625] Resolver error: Connecting was canceled
[11:53:18.640] ------

Again, I can connect to the same linux server via ssh from my local machine (Win 10) without any problems.

3
I've run into a similar issue; possibly related to an open bug with specific combinations of versions? github.com/microsoft/vscode-remote-release/issues/2788 - VictorLegros

3 Answers

1
votes

I've resolved the connection issues; possibly the ssh config was not correctly saved/accessed by VS Code?

I thought I should be able to directly set it up to point to an existing config file, but that didn't seem to work. Instead, I created a new config file in the UI, and over-wrote the contents. Shouldn't be necessary, but seemed to do the trick.

What I did was:

  1. Add new host: => Remote-SSH: Connect to host... => Add New SSH Host...
  2. Type in command: ssh user@host to attempt to connect
  3. Choose platform in the command bar in the new window (Linux in my case)
  4. Verify connected (I needed to change ssh-agent settings to store credentials)
  5. Edit the config location: => Remote-SSH: Connect to host... => Settings
  6. Enter config file under Remote.SSH: Config File (C:\Users\me\.vagrant\machines\default\virtualbox\config in my case)
  7. Modify config file further, as needed
  8. Connect through the UI: Remote-SSH: Connect to host... =>

Hope that helps!

0
votes

For me it was not starting necessary SSH*. See status services using: Get-Service SSH* on PowerShell. I got a time out error on enabling necessary services and this helped.

0
votes

A colleague of mine was with this problem. We solved just deleting his %USERPROFILE\.ssh\config file, closing VSCode, reopening it, and trying to connect again.

There was some garbage in his ssh config file.