64

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] [email protected]
[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] ------
7
  • 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, 2020 at 3: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, 2020 at 4:11
  • can you connect to the host using your terminal?
    – andre
    Jan 30, 2020 at 4:18
  • yes,I can connect to the host using cmd.exe in windows by ssh
    – peng zhang
    Jan 30, 2020 at 4:25
  • Is "23321" really the hostname? Some software would interpret a digit string as an IP address.
    – Kenster
    Jan 30, 2020 at 13:08

15 Answers 15

90

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

3
  • 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 2, 2021 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, 2021 at 12:36
  • A little more information is given here Dec 15, 2021 at 20:08
79

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.
3
  • 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 3, 2021 at 22:41
  • 4
    For me setting it 60 or even 300 does not solve the issue.
    – Atif Ali
    Mar 27, 2022 at 8:23
  • Thanks! For me setting it 60 solved the issue
    – Creeki
    Mar 22 at 10:27
10

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

1
  • For me, setting it 60 - 100 doesn't solve the issue.
    – aksyuma
    Dec 15, 2022 at 21:07
10

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.

1
  • 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 at 8:28
7

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

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

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

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.

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.

4
  • 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.
    – Community Bot
    Jun 8, 2022 at 15:43
  • damn right bot, that answer was doodoo.
    – sansa
    Jun 22, 2022 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. Jun 23, 2022 at 6:11
  • Doesn't work for me.
    – Bagusflyer
    Jun 2 at 6: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!

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.

0

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

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

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.

0

My issue was similar to above posts, I just opened command palette (Ctrl+shift+p), searched Remote-SSH settings, and changed the timeout from 15 seconds to something longer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.