VS Code Remote SSH Connection not working

44,635

Solution 1

Depending on the system you are in! When you first try to connect! A vscode-server will be set up and configured on your server!

In linux that can be in /Home/<user>/.vscode-server !

If you are on windows check what that is!

The first solution is to try the extension command: Remote-SSH: kill VS Code Server on Host

Open the command pallet (CTRL + SHIFT + P or COMMAND + SHIFT + P (mac) ).

And type Remote kill :

enter image description here

Then try to connect again! (That will kill the server on the host! Which will make it start again on the next try)

If that doesn't work! And still failing!

Delete, rm

Then a good solution that can work is: to connect to your server through terminal (vscode terminal, gnome-terminal, whatever)! Then go and remove /Home/<user>/.vscode-server

Try to connect after it! At the attempt the server will be re-installed completly all anew! And good chances it will works! (I did that and it worked! So whatever that was going wrong on the vscode-server! you start all over! And the state or whatever go a new and problem resolved!

However you loose things, config, meta data, ... (you start a new!) In my case it didn't matter! (Note: check the update section. If u don't want to loose the settings data ...)

One can explore the .vscode-server structure, and elements! And you can save some part that you bring up later! (I didn't check!) (may do later)! It's an option!

Update:

As stated by @natevw im the comments:

I found that removing only the .vscode-server/bin subfolder helped straighten things out and afaict kept my data/settings.

Removing only vscode-server/bin seems to work well. And the config, metadata remains untouched.

Solution 2

I downgrade Remote-SSH plugin to 0.51.0, rm -rf $HOME/.vscode-server on the remote machine. Connect again, VSCode will download and install a new .vscode-server. Then upgrade Remote-SSH plugin, everything works.

Solution 3

I met the same problem. After I did these steps, it works:

on the remote server:

rm -rf ~/.vscode-server  
rm -rf ~/.vscode

On the local VS code:

reinstall remote-ssh

Solution 4

One way worked for me is, by adding this line in the vscode settings (JSON) file.

"remote.SSH.useLocalServer": false

VSCode settings

Share:
44,635

Related videos on Youtube

000
Author by

000

Updated on July 09, 2022

Comments

  • 000
    000 almost 2 years

    Im trying to setup vscode with the remote developement extensions on a second pc. While it works on my main one it doesnt on the second one. Tried reinstalling vscode, extensions and using older versions but nothing works.

    When trying to connect it cancels after chosing the os. So I cant even type in the password. I set it up in the exact same way as with the other pc.

    Any ideas?

    [20:32:53.595] [email protected]
    [20:32:53.595] win32 x64
    [20:32:53.596] SSH Resolver called for "ssh-remote+ssh.blabla", attempt 1
    [20:32:53.597] SSH Resolver called for host: ssh.blabla
    [20:32:53.597] Setting up SSH remote "ssh.blabla"
    [20:32:53.610] Using commit id "58bb7b2331731bf72587010e943852e13e6fd3cf" and quality "stable" for server
    [20:32:53.612] Install and start server if needed
    [20:32:54.639] Checking ssh with "ssh -V"
    [20:32:54.686] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
    
    [20:32:54.691] Running script with connection command: ssh -T -D 52819 ssh.blabla bash
    [20:32:54.694] Terminal shell path: C:\WINDOWS\System32\cmd.exe
    [20:32:54.758] >
    ]0;C:\WINDOWS\System32\cmd.exe
    [20:32:54.758] Got some output, clearing connection timeout
    [20:32:54.785] >
    [20:32:55.045] > root@blabla's password: 
    [20:32:55.045] Showing password prompt
    [20:32:57.596] "install" terminal command done
    [20:32:57.597] Install terminal quit with output: root@blabla's password: 
    [20:32:57.597] Received install output: root@blabla's password: 
    [20:32:57.598] Stopped parsing output early. Remaining text: root@blabla's password:
    [20:32:57.598] Failed to parse remote port from server output
    [20:32:57.603] Resolver error: Error: 
        at Function.Create (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:1:130564)
        at Object.t.handleInstallOutput (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:1:127671)
        at I (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:106775)
        at processTicksAndRejections (internal/process/task_queues.js:94:5)
        at async c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:104774
        at async Object.t.withShowDetailsEvent (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:109845)
        at async Object.t.resolve (c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:107960)
        at async c:\Users\Manuel.vscode\extensions\ms-vscode-remote.remote-ssh-0.55.0\out\extension.js:127:141955
    [20:32:57.606] ------
    
    
    
    
    [20:32:59.376] Password dialog canceled
    [20:32:59.376] "install" terminal command canceled```
    
  • user14063792468
    user14063792468 over 3 years
    @Yatin Not anymore for what person? I still can not see the question.
  • Sabito 錆兎 stands with Ukraine
    Sabito 錆兎 stands with Ukraine over 3 years
    The answer doesn't have formatting issues anymore..
  • Deepak Sadulla
    Deepak Sadulla over 3 years
    This worked for me as well.. I was able to ssh through command prompt, delete the .vscode-server file in home and tried ssh through VSCode and it worked... Thanks!!
  • Sebastian Dengler
    Sebastian Dengler about 3 years
    Thanks a lot. This saved me a lot of trouble!
  • Apinorr
    Apinorr over 2 years
    Hi, how do I open this window where I type remote kill please?
  • Mohamed Allal
    Mohamed Allal over 2 years
    Hi, It's the command pallet. You can do that with CTRL + SHIFT + P (or COMMAND + SHIFT + P in mac)
  • vasu
    vasu about 2 years
    That is really helpful. Been searching the solution for days and glad that I pondered on your solution. But may I know why do we have to kill VS code server?
  • Christian Luneborg
    Christian Luneborg about 2 years
    That didnt work for me.
  • natevw
    natevw about 2 years
    I found that removing only the .vscode-server/bin subfolder helped straighten things out and afaict kept my data/settings.
  • ameerosein
    ameerosein about 2 years
    Worked for me without even downgrading! only removed the dir on the host and tried connecting again.
  • Mohamed Allal
    Mohamed Allal about 2 years
    Thanks for sharing that. That's great. I'll add a note to the answer.