wen
wen

Reputation: 955

Could not establish connection to "hostname". (Remote-SSH problem in VSCode ) (CentOS7)

[SOLVED!!]

I connected to my server by ssh

ssh [email protected]

I try to open VSCode by local, and using Remote-SSH -> Connected to SSH -> type [email protected]

Then got Could not establish connection to "@ln01.twcc.ai". Error block and output is like as below

[11:37:51.572] Log Level: 2
[11:37:51.574] [email protected]
[11:37:51.574] win32 x64
[11:37:51.575] SSH Resolver called for "ssh-remote+...", attempt 1
[11:37:51.575] "remote.SSH.useLocalServer": false
[11:37:51.575] "remote.SSH.showLoginTerminal": false
[11:37:51.575] "remote.SSH.remotePlatform": {}
[11:37:51.575] "remote.SSH.path": undefined
[11:37:51.575] "remote.SSH.configFile": undefined
[11:37:51.575] "remote.SSH.useFlock": true
[11:37:51.576] "remote.SSH.lockfilesInTmp": false
[11:37:51.576] "remote.SSH.localServerDownload": auto
[11:37:51.576] "remote.SSH.remoteServerListenOnSocket": false
[11:37:51.576] "remote.SSH.showLoginTerminal": false
[11:37:51.576] "remote.SSH.defaultExtensions": []
[11:37:51.576] "remote.SSH.loglevel": 2
[11:37:51.576] SSH Resolver called for host: ssh [email protected]
[11:37:51.576] Setting up SSH remote "ln01.twcc.ai"
[11:37:51.592] Using commit id "..." and quality "stable" for server
[11:37:51.595] Install and start server if needed
[11:37:56.696] Checking ssh with "ssh -V"
[11:37:56.726] > OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2

[11:37:56.729] Running script with connection command: ssh -T -D 53574 "ssh [email protected]" bash
[11:37:56.731] Terminal shell path: C:\Windows\System32\cmd.exe
[11:37:56.948] > ]0;C:\Windows\System32\cmd.exe
[11:37:56.948] Got some output, clearing connection timeout
[11:37:57.376] > 

[11:37:59.421] > ssh [email protected]: Permission denied (publickey,gssapi-keyex,gssapi-with
> -mic,keyboard-interactive).
[11:37:59.434] > 程序嘗試寫入到一個不存在的管道。
[11:38:00.713] "install" terminal command done
[11:38:00.714] Install terminal quit with output: 程序嘗試寫入到一個不存在的管道。
[11:38:00.714] Received install output: 程序嘗試寫入到一個不存在的管道。
[11:38:00.714] Failed to parse remote port from server output
[11:38:00.715] Resolver error: Error: 
    at Function.Create (c:\Users\ASUS\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:64659)
    at Object.t.handleInstallOutput (c:\Users\ASUS\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:63302)
    at Object.t.tryInstall (c:\Users\ASUS\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:415135)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async c:\Users\ASUS\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:294918
    at async Object.t.withShowDetailsEvent (c:\Users\ASUS\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:406463)
    at async Object.t.resolve (c:\Users\ASUS\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:1:295994)
    at async c:\Users\ASUS\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.7\out\extension.js:127:110656
[11:38:00.718] ------

Summary

Error Block

Upvotes: 8

Views: 82329

Answers (14)

Ontoshka
Ontoshka

Reputation: 26

In my case the solution was tweaking the ssh config on the remote

https://www.simplified.guide/ssh/limit-simultaneous-connections#:~:text=You%20can%20control%20the%20number,handle%20at%20the%20same%20time.

I was having issues when loading more than one vscode window with connection to the same remote machine with the error code of Could not establish connection to "": CodeError(AuthChallengeBadToken)

Changed settings to

$ cat /etc/ssh/sshd_config | grep Max
MaxAuthTries 60
MaxSessions 100
#ClientAliveCountMax 3
MaxStartups 200

And the error resolved

Upvotes: 0

kehao chen
kehao chen

Reputation: 1

In my case,

rm -rf ~/.vscode-server

and reconnect the server can solve this problem.

Upvotes: 0

Peterson Yuhala
Peterson Yuhala

Reputation: 36

Delete the folder ~/.vscode-server/ on the remote server and delete the known_hosts files on the local machine. Then try connecting again via SSH from VS Code: Ctrl + Shift + P --> Remote-SSH ...

Upvotes: 0

YiDDcode
YiDDcode

Reputation: 1

Delete all fingerprint files, including known_hosts and known_hosts.old

Files are located in the Windows system: C:\Users\<your_user_name>\.ssh directory

Upvotes: 0

In my case, the problem was that the permissions on the "C:\users<user>.ssh" folder had been changed. I just deleted it. You can make sure that you have the same problem by connecting to your server via ssh (using powerShell).

Upvotes: 0

Burak Tamince
Burak Tamince

Reputation: 41

Adding new remote host with same properties worked for me

Upvotes: 0

Armaan Sengupta
Armaan Sengupta

Reputation: 3

I had to add PowerShell to system path on the machine I was trying to connect to. You can quickly check if you need to do this by typing PowerShell in cmd on that machine, if you get an error like PowerShell is not recognized as an internal or external command" then add this variable to path %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

Where you replace %SYSTEMROOT% with the path to right before system32 on that machine.

How to add to path.

Upvotes: 0

WMax
WMax

Reputation: 67

In my case the problem turned out to be that there was no free disk space on the server (also logs in vscode were different).

Disk usage can be checked with: df -h

Upvotes: 1

vjaidegavi
vjaidegavi

Reputation: 11

Yea I was also facing same issue when I updated my VS code to latest version 1.75.1 Facing issue "Connection failed XSH issue"

This is because of proxy issue with you linux machine where your VS code is trying to connect .

Solution:

  1. 'Navigate to Linux machine--> and perform below operation [user @linuxmachineip] : cd .vs code-server/ (navigate to vs code-sever folder)
  2. [user @linuxmachineip .vs code-server] : SU - (login as Root user)
  3. [user @linuxmachineip .vs code-server] : cd / etc / profile.d (navigate to etc/profile.d folder)
  4. [user@linuxmachineip .vscode-server] : mv proxy.sh.off proxy.sh (rename proxy.sh.off to proxy.sh ***** as this will enable your vscode to connect to internet to download all necessary files in profile.d folder )
  5. Now relaunch your VS code and try to connect . (it will connect now) And then again come back to Linux machine
  6. [user@linuxmachineip .vscode-server] mv proxy.sh proxy.sh.off (rename proxy.sh to proxy.sh.off ***** as this will disable again)'

Upvotes: 0

hjc
hjc

Reputation: 17

I have faced the problem many times. Restart the vscode program always resolve my problem.

Upvotes: -2

pateheo
pateheo

Reputation: 440

If Kill VS Code Server on Host won't help (after you have tried that!), then make a refresh on local machine by:

  1. Delete ~/.vscode
  2. Delete ~/.config/Code

Then re-install the latest version of VSCode. It will work.

Upvotes: 0

user3503711
user3503711

Reputation: 2046

Here is what worked for me:

  1. Open the command panel on VS code (Ctrl+Shift+P for Windows and Cmd+Shift+P for Mac).
  2. Search for Kill VS Code Server on Host, click it - it will be automatically deleted.
  3. Reload VS Code and establish connection again.

For more details, please visit here.

Upvotes: 15

wen
wen

Reputation: 955

I solved it by writing SSH config files first before remoting.

If you connected to server by ssh like:

ssh [email protected] -p 22

Then config file would be:

Host MyHostName
    HostName 123.456.78.999
    User Amy
    Port 22

reference: https://github.com/microsoft/vscode-remote-release/issues/3968

Upvotes: 3

cestpasmoi
cestpasmoi

Reputation: 655

Try to delete the fingerprint (a single line that corresponds to this particular connection - not the whole file) saved within the known_hosts file. If in Windows, this is placed at C:\Users\<your_user_name>\.ssh\known_host whereas for Linux that would be within /home/<your_user_name>/.ssh/known_hosts dir.

Since more detailed, you may also want to check this answer too.

Upvotes: 18

Related Questions