6

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] remote-ssh@0.51.0
[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.

clex
  • 465
  • 2
  • 7
  • 19
  • Does this answer your question? [Can't connect VS Code to Linux machine for remote development](https://stackoverflow.com/questions/60974357/cant-connect-vs-code-to-linux-machine-for-remote-development) – r3zaxd1 May 17 '20 at 14:05
  • I've run into a similar issue; possibly related to an open bug with specific combinations of versions? https://github.com/microsoft/vscode-remote-release/issues/2788 – VictorLegros Jun 07 '20 at 20:55

8 Answers8

2

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!

VictorLegros
  • 380
  • 1
  • 4
  • 13
0

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.

ArdentLearner
  • 712
  • 7
  • 20
0

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.

neves
  • 33,186
  • 27
  • 159
  • 192
0

I also found that if the value of the "Host" field includes a ")" character, then there will be an error message as follows and the VSCode keeps trying opening remote:

The terminal process "C:\WINDOWS\System32\cmd.exe /c (type "C:\Users\xxxxx_xxxxx\AppData\Local\Temp\vscode-linux-multi-line-command--ccton_---_---2-705401992.sh" | ssh -T -L 127.0.0.1:53080:/run/user/1000/vscode-ssh-remote-server-sock-1636523090 Accton_AWS_EC)2 bash) & exit /b 0" terminated with exit code: 1.
skyline
  • 443
  • 9
  • 31
0

I tried the following that worked for me:

  1. Click on View > Command Palette (alternatively press CTRL + Shift + P)

  2. Start typing:

Remote SSH: Kill

  1. Click on the first option that says: Remote-SSH: kill VS Code Server on Host...

  2. From the options, click on the server you are having trouble connecting to. This will kill that VScode server.

  3. Now just try to reconnect: a. View > Command Palette (alternatively press CTRL + Shift + P) b. Start typing: SSH Remote-SSH: Connect to host... c. Select the server.

Ahsan Tarique
  • 581
  • 1
  • 11
  • 22
0

Adding my 2 cents here, I too had lots of trouble connecting to a remote using "Remote SSH Extension of Microsoft". Unfortunately, no luck and spent a lot of time trying all ways possible.

I found another extension named "SSH Client" by cweijan. It was easy and I was able to access my remote using it.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Shivam Papat
  • 457
  • 4
  • 14
0

When I had this issue it was because the extension was complaining that the pem file permissions were too open, it should be accessible just by my current user.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 07 '22 at 13:00
0

Yes, I would like to ~ add on top of Shivam Popat's answer.

ssh-client-cweijan

Configure F1 ssh.add and Option to add client, and password appears.

Now, connect, and save.

From the left pane you would see icon of key. and upon clicking it will open the remote folders.

The previous problem with VScode remote SSH resolved.

Paul Bradbury
  • 482
  • 6
  • 8