Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why ssh connection timed out in vscode?

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] ------
like image 473
peng zhang Avatar asked Jan 30 '20 03:01

peng zhang


People also ask

Why is SSH connection timed out?

This error message comes from the SSH client. The error indicates that the server didn't respond to the client and the client program gave up (timed out). The following are common causes for this error: The security group or network ACL doesn't allow access.

Can VS Code connect to SSH?

VS Code Remote SSH You can connect over SSH into another machine from Visual Studio Code and interact with files and folders anywhere on that remote filesystem. If you have an app located on a different computer, you could use SSH to connect to it and access your app, view its files, and even modify, run, and debug it.

How do I set SSH connection timeout?

Use the ssh_timeout command to set the number of minutes that the SSH session can be idle before it is closed. The default timeout interval is 0 minutes. Use this value, if you do not want the SSH session to expire. The minimum timeout interval is 2 minutes.

How add SSH key to VS Code?

Add SSH key to your VM# Select Use existing public key in the dropdown for SSH public key source so that you can use the public key you just generated. Take the public key and paste it into your VM setup, by copying the entire contents of the id_ed25519. pub in the SSH public key.


2 Answers

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

like image 59
Snehal Parmar Avatar answered Oct 10 '22 04:10

Snehal Parmar


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.
like image 56
Yonti Avatar answered Oct 10 '22 03:10

Yonti