62

I installed git instead of openssl to use Remote-SSH in VSCode.However,after I completed the config document and tried to connect to the remote host.I failed. The error info is showed in the below pic.error info

error info:

[11:27:12.631] remote-ssh@0.48.0
[11:27:12.632] win32 x64
[11:27:12.656] SSH Resolver called for "ssh-remote+23321", attempt 1
[11:27:12.659] SSH Resolver called for host: 23321
[11:27:12.659] Setting up SSH remote "23321"
[11:27:12.790] Using commit id "26076a4de974ead31f97692a0d32f90d735645c0" and quality "stable" for server
[11:27:12.798] Testing ssh with ssh -V
[11:27:13.099] ssh exited with code: 0
[11:27:13.100] Got stderr from ssh: OpenSSH_8.1p1, OpenSSL 1.1.1d  10 Sep 2019
[11:27:13.128] Running script with connection command: ssh -T -D 49485 23321 bash
[11:27:13.132] Install and start server if needed
[11:27:13.151] Terminal shell path: C:\Windows\System32\cmd.exe
[11:27:30.151] Resolver error: Connecting with SSH timed out
[11:27:30.178] ------
peng zhang
  • 621
  • 1
  • 5
  • 3
  • 1
    have you tried removing the single quotes from the first block? just like you tried on the second block, but on the second block, you don't set the IdentyFile. – andre Jan 30 '20 at 03:58
  • I have tried to connect with or without single quotes and IdentifyFile. But it made no difference. The results are the same: 'Connecting with SSH timed out' – peng zhang Jan 30 '20 at 04:11
  • can you connect to the host using your terminal? – andre Jan 30 '20 at 04:18
  • yes,I can connect to the host using cmd.exe in windows by ssh – peng zhang Jan 30 '20 at 04:25
  • Is "23321" really the hostname? Some software would interpret a digit string as an [IP address](http://man7.org/linux/man-pages/man3/inet.3.html#DESCRIPTION). – Kenster Jan 30 '20 at 13:08
  • I have the same issue with an Ubuntu client and remote server. Removing my ~/.config/code directory fixes it, but this is clearly not a good option since it removes many other settings as well. – brakus Feb 03 '20 at 02:45
  • I can see the welcome message already. Then timeout. *stderr> Authenticated to xxxxx ([IP]:22) using "password". > Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.2.0 x86_64)* – Bagusflyer Jun 02 '23 at 06:04

14 Answers14

85

I had the same problem but the above solutions didn't work with my setup, but the following setting did work:

"remote.SSH.useLocalServer": false

I got this solution from github reported issues and fix

Snehal Parmar
  • 5,453
  • 3
  • 35
  • 46
  • 2
    I can add that this might have something to do with the ControlPersist option being enabled n `~/.ssh/config` since I was not having any issues with this until I turned this flag on – Ben Feb 02 '21 at 10:58
  • Thank you! Your suggestions set me up on the right path - I had Fig setup in `~/.ssh/config`, diasbling solved the issue – Leo Jun 27 '21 at 12:36
  • A little more information is given [here](https://github.com/microsoft/vscode-remote-release/issues/5925#issuecomment-982887377) – DilithiumMatrix Dec 15 '21 at 20:08
77

In my case, the problem was caused by a too long authentication process on the server-side.

Solved it by extending the Connect Timeout from 15 to 30 seconds.

Instructions:

  1. open your vscode Command Palette (via keyboard shortcut or from the View menu).
  2. search for the Remote-SSH: Settings.
  3. scroll till you find the Connect Timeout.
  4. change it to a longer duration than 15 secs.
Yonti
  • 1,179
  • 9
  • 8
  • 5
    I don't understand why vscode has a default ConnectTimeout value in the first place, nor why it is so low (15 seconds). The default should be to use whatever the user has configured SSH to (in general or for that host). I'll add that SSH actually doesn't have an explicit default value either, it uses the TCP default (as it should). – studgeek Sep 03 '21 at 22:41
  • 4
    For me setting it 60 or even 300 does not solve the issue. – Atif Ali Mar 27 '22 at 08:23
  • Thanks! For me setting it 60 solved the issue – Creeki Mar 22 '23 at 10:27
10

key F1 Remote-SSH: Settings Connect Timeout: from 15 seconds to 60 seconds solve my connection issue

franman726
  • 111
  • 2
  • 2
9

You can try the following approaches:

  1. ssh to your remote server. Then run the following commands to clean data folder and bin folder under .vscode-server folder on the server:
  • cd ~/.vscode-server
  • rm data/* -rf
  • rm bin/* -rf
  1. If step 1 does not work, ssh to your remote server and delete the entire .vscode-server folder with the following command:

    rm -rf ~/.vscode-server

    Please note that this will also remove the extensions that you installed on the server.

  2. Downgrade the version of the remote-SSH extension in vscode. Look up the extension in the vscode interface, right click on that, and you will find the option "Install Another Version ...". Install the previous version of the current one. If it does not work keep downgrading the version.

smsarwar
  • 351
  • 3
  • 3
  • This worked for me, but I still had to reboot the box. I think its more to it than just this folder. (note: regular SSH worked fine and in just a few seconds, so its not really a 15second timeout issue in my case) – SpiRail Jul 19 '23 at 08:28
7

I had the same problem before, I solved this by deleting "terminal.integrated.inheritEnv": false inside ~/.config/Code/User/setting.json

EequalsMC2
  • 71
  • 2
5

I found the solution here in this thread from user oreilm49: https://github.com/microsoft/vscode-remote-release/issues/1137

in vscode settings : search conpty and uncheck it

jaques-sam
  • 2,578
  • 1
  • 26
  • 24
5

I had same issue, my problem was solved after changing settings in the json file:

  1. I removed "terminal.integrated.inheritEnv": false inside ~/.config/Code/User/setting.json
  2. I added "remote.SSH.useLocalServer": true inside ~/.config/Code/User/setting.json

It worked for me after so many different trials

Ryan M
  • 18,333
  • 31
  • 67
  • 74
Sobia Rind
  • 61
  • 1
  • 3
3

This might be a very foolish solution but it actually works for me, so I will write it down in case any other people get into the same problem. I made modifications to the config file for SSH, then all the trials for connection ran into the error of 'Connecting SSH timed out'. I tried many possible solutions but none of them solved my problem.

Then I just closed the VScode and restarted it. Then everything works.

formt
  • 78
  • 7
3

I had a case of this. I my client (local computer) is a Mac, and I was connecting to Linux host. I just went to the setting "Remote Platform" under Remote.SSH settings, and explicitly told it that I am connecting to a Linux remote. After this, it started to work.

  • 2
    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 Jun 08 '22 at 15:43
  • damn right bot, that answer was doodoo. – sansa Jun 22 '22 at 20:05
  • 1
    Go to VSCode preferences, search for `Remote.SSH: Remote Platform`. The top result should be the relevant preference. Click `Add Item`. Under "Item", enter the hostname you're trying to connect to. Under "Value", select "Linux". This worked for me. – incidentist Jun 23 '22 at 06:11
  • Doesn't work for me. – Bagusflyer Jun 02 '23 at 06:08
1

Well before trying all of the above methods, try the nice old method: restart your PC.

I tried all the suggested methods and nothing worked for me, then I just turned off and then on and everything is magically working!

Youcef4k
  • 338
  • 2
  • 13
1

For me the issue was that on the server I wanted to connect to, the /etc/ssh/sshd_config contained:

AllowTcpForwarding no

Changing that to

AllowTcpForwarding yes

Did solve my ssh connection timeout issue.

Karsten Becker
  • 502
  • 5
  • 11
0

I had this issue because of version missmatch of client and server. After updating both to the same version, it worked for me.

Barkaas
  • 46
  • 5
0

The issue with me was timeout at first. I tried increasing the timeout in settings but then later found the issue was with "tar".

The vscode-server.tar.gz (probably a little change in the file name) was not able to install due to tar not being present in my host. So I installed tar in the host as "yum install tar" And then tried reconnecting to the server and it worked

Shivam Papat
  • 457
  • 4
  • 14
0

Been struggling with this for a while now... i keep trying to resolve it but unsuccessfully, although i do have a workaround.

My situation is that I regularly run 3 projects together in separate VSCode windows, and one particular project always has this issue lately (especially after a VSCode release restart), even though they are all on the same remote server within my user directory.

The only way i can resolve it (the workaround) is to:

  • close VSCode
  • go to my user dir in Windows \AppData\Roaming\Code\User\workspaceStorage
  • delete the folders (or just the latest timestamp one if you know this is definitely the one for the project with the issue)

Note: i run Windows locally and RHEL remotely.

Aaron Williams
  • 655
  • 4
  • 11