VSCode RemoteSSH - connection timeout - visual-studio-code

Beginning today, I am unable to connect to my remote server in VSCode. The error in the output shows this repeating 5 times:
[15:34:11.799] SSH Resolver called for "ssh-remote+my-server", attempt 5, (Reconnection)
[15:34:11.805] SSH Resolver called for host: my-server
[15:34:11.808] Setting up SSH remote "my-server"
[15:34:11.819] Using commit id "d045a5eda657f4d7b676dedbfa7aab8207f8a075" and quality "stable" for server
[15:34:11.832] Install and start server if needed
[15:34:11.849] Running script with connection command: ssh -T -D 53101 "myserver" bash
[15:34:11.857] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[15:34:28.879] Resolver error: Error: Connecting with SSH timed out
at g.Timeout (c:\Users\username\.vscode\extensions\ms-vscode-remote.remote-ssh-0.90.1\out\extension.js:1:585348)
at Timeout._onTimeout (c:\Users\username\.vscode\extensions\ms-vscode-remote.remote-ssh-0.90.1\out\extension.js:1:679743)
at listOnTimeout (node:internal/timers:559:17)
at process.processTimers (node:internal/timers:502:7)
[15:34:28.948] ------
The port number in that SSH command is different for each attempt. If I copy that command out and run it in cmd manually from my local machine and add in -vvv, then I see the connection is successful and the prompt sits on "debug2: exec request accepted on channel 2" infinitely. I can't tell what the problem is. Is the local forwarding port failing to be created and listen on? Is there something with the remote server causing the timeout? Oddly, if I delete the .vscode-server directory on the remote and try to reconnect, then it actually does reinstall it fine. But I still get the error that VSCode can't connect to the remote server.

I forgot that the VSCode Remote extensions have their own repository. Turns out my issue is https://github.com/microsoft/vscode-remote-release/issues/7324
Ensuring that I set remote.SSH.useLocalServer to true in my user settings.json fixed the issue until it is resolved in-code.

Related

VS Code Remote-SSH won't reconnect to one specific working directory on remote Ubuntu host

I'm using VSCode 1.72.2 with Remote-SSH v0.90.1 on Windows to develop against an AWS EC2 VM running Ubuntu 22.04 LTS. A couple days ago, I was working in my project source folder in /opt/t4/ on the target host. When I was finished, I stopped the VM from the AWS console, forgetting that VS Code was still SSHed in.
When I brought the VM back up, I can reconnect VS Code/Remote-SSH to the host as before, except that I can no longer connect using /opt/t4/ as my working directory. I can use any directory except the one I was using when I disconnected.
I can navigate down to it and work in it if I use /opt/ as my working directory. I can navigate to it by manually SSHing to the remote host. I can create a subfolder in a remote shell at /opt/t4/test/, and then connect VS Code using that subfolder as my working directory. I can see and select /opt/t4/ in the Open Folder dialog in VS Code. But when I try to connect using that working directory, the connection times out with a not-particularly-useful error message:
[00:05:49.867] SSH Resolver called for "ssh-remote+my.remote.host", attempt 2, (Reconnection)
[00:05:49.868] SSH Resolver called for host: my.remote.host
[00:05:49.868] Setting up SSH remote "my.remote.host"
[00:05:49.870] Using commit id "d045a5eda657f4d7b676dedbfa7aab8207f8a075" and quality "stable" for server
[00:05:49.872] Install and start server if needed
[00:05:49.874] Using SSH config file "C:\Users\me\.ssh\config"
[00:05:49.874] Running script with connection command: ssh -T -D 1518 -F "C:\Users\me\.ssh\config" "my.remote.host" bash
[00:05:49.875] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[00:06:06.876] Resolver error: Error: Connecting with SSH timed out
at g.Timeout (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.90.1\out\extension.js:1:585348)
at Timeout._onTimeout (c:\Users\me\.vscode\extensions\ms-vscode-remote.remote-ssh-0.90.1\out\extension.js:1:679743)
at listOnTimeout (node:internal/timers:559:17)
at process.processTimers (node:internal/timers:502:7)
[00:06:06.877] ------
I tried Remote-SSH: Uninstall VS Code Server from Host from VS Code.
I tried deleting ~/.vscode-server on the Linux host from an SSH session.
I tried Remote-SSH: Kill VS Code Server on Host from VS Code.
I tried Remote-SSH: Kill Local Connection Server for Host from VS Code.
I tried deleting and recreating the host connection details in the local config file from SSH-Remote.
I tried rebooting both local and target hosts.
I tried setting /opt/ as my working dir, then deleting and recreating /opt/t4. I was able to do this, but as soon as I try reconnecting using /opt/t4 as the working dir, VS Code still fails to connect.
I'm... stumped. My suspicion is that there is something corrupt cached Windows-side, but I don't know where to look for that.
Microsoft is aware and working on a fix. There are a variety of workarounds in this thread: https://github.com/microsoft/vscode-remote-release/issues/7324
Thanks to the link from #Mike Barry, I managed to find the local workspace for that target folder and delete it to force it to reinitialize, which cleared the issue.
Deleted C:\Users\me\AppData\Roaming\Code\User\workspaceStorage\[guid]\ and reconnected with no problem.

Why Connecting with SSH of VS Code I cannot open a specific folder?

I usually connect to remote computers through VS Code SSH. The settings (IP of the remote computer and public and private key pairs are properly set). The strange thing that is happening is that I can open any folder in the remote computer, but not the folder where the project is located (for example, I can also open the parent folder of the project).
It was working properly for years and now it has this type of problem.
Here, I report the output terminal:
[21:03:16.164] "remote.SSH.serverInstallPath": {}
[21:03:16.168] SSH Resolver called for host: PC000
[21:03:16.168] Setting up SSH remote "PC000"
[21:03:16.173] Using commit id "6261075646f044b98968d5000324gdhsdsjdd3b" and quality "stable" for server
[21:03:16.177] Install and start server if needed
[21:03:16.182] Checking ssh with "ssh -V"
[21:03:16.261] > OpenSSH_for_Wind
[21:03:16.262] > ows_8.1p1, LibreSSL 3.0.2
[21:03:16.273] Running script with connection command: ssh -T -D 64484 "PC000" bash
[21:03:16.275] Terminal shell path: C:\Windows\System32\cmd.exe
And after a while, it returns the timeout error.
I am putting the passphrase which it is requesting, then it is not able to connect to the folder.
Do anyone have some ideas?
I tried to open other folders with VS Code SSH connection and they are propery opened. I browsed with the command window to to the folder of the project and everything seem fine.
Did you try this option? "remote.SSH.useLocalServer": false, for more details, you can have a look the discussion here
Setting the terminal.integrated.inheritEnv option to true solved the problem

VScode SSH extension keeps disconnecting after moving to a new location

I recently moved to a different country, but I work remotely and therefore I thought that my workspace wouldn't be interrupted. However, now that I'm trying to connect to my workspace through ssh in vscode, the connection keeps disconnecting. I connect to the workspace through the VPN my workspace provides, and while I can connect to the linux box I work in via ssh, I cannot connect to it through vscode-remote-ssh extension like I did for the past few months. Nothing has changed in terms of settings on my computer. I attached the output vscode provides when I tried to connect below (this is the output from the reconnection attempt but the first connection attempt looks exactly the same).
[15:36:11.086] ------
[15:36:11.086] SSH Resolver called for "ssh-remote+203.0.113.0", attempt 2, (Reconnection)
[15:36:11.087] SSH Resolver called for host: 203.0.113.0
[15:36:11.087] Setting up SSH remote "203.0.113.0"
[15:36:11.091] Using commit id "e5e9e69aed6e1984f7499b7af85b3d05f9a6883a" and quality "stable" for server
[15:36:11.092] Install and start server if needed
[15:36:11.096] Using SSH config file "C:\Users\windowsUser\.ssh\config"
[15:36:11.096] Running script with connection command: ssh -T -D 53043 -F "C:\Users\windowsUser\.ssh\config" 203.0.113.0 bash
[15:36:11.101] Terminal shell path: C:\Windows\System32\cmd.exe
[15:36:11.240] >
[15:36:11.240] Got some output, clearing connection timeout
[15:36:13.669] > linuxUser#203.0.113.0's password:
[15:36:13.670] Showing password prompt
[15:36:29.329] Got password response
[15:36:29.330] "install" wrote data to terminal: "*******"
[15:36:29.358] >
>
[15:36:31.047] > 3a294560e95d: running
> Acquiring lock on /home/linuxUser/.vscode-server/bin/e5e9e69aed6e1984f7499b7af85b3
> d05f9a6883a/vscode-remote-lock.linuxUser.e5e9e69aed6e1984f7499b7af85b3d05f9a6883a
>
[15:36:31.073] > Found existing installation at /home/linuxUser/.vscode-server/bin/e5e9e69aed6e1984
> f7499b7af85b3d05f9a6883a...
> Found running server...
>
> *
> * Reminder: You may only use this software with Visual Studio family products,
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057)
> *
>
> Checking server status on port 34103 with wget
>
[15:36:31.108] > 3a294560e95d: start
>
[15:36:31.391] > sshAuthSock====
> listeningOn==34103==
> osReleaseId==ubuntu==
> arch==x86_64==
> webUiAccessToken====
> tmpDir==/run/user/1000==
> platform==linux==
> 3a294560e95d: end
>
[15:36:31.391] Received install output:
sshAuthSock====
listeningOn==34103==
osReleaseId==ubuntu==
arch==x86_64==
webUiAccessToken====
tmpDir==/run/user/1000==
platform==linux==
[15:36:31.392] Remote server is listening on 34103
[15:36:31.392] Parsed server configuration: {"remoteListeningOn":{"port":34103},"osReleaseId":"ubuntu","arch":"x86_64","webUiAccessToken":"","sshAuthSock":"","tmpDir":"/run/user/1000","platform":"linux"}
[15:36:31.393] Starting forwarding server. localPort 53048 -> socksPort 53043 -> remotePort 34103
[15:36:31.395] Forwarding server listening on 53048
[15:36:31.395] Waiting for ssh tunnel to be ready
[15:36:31.396] Tunneled 34103 to local port 53048
[15:36:31.396] Resolved "ssh-remote+203.0.113.0" to "127.0.0.1:53048"
[15:36:31.397] [Forwarding server 53048] Got connection 0
[15:36:31.402] ------
[15:36:31.430] [Forwarding server 53048] Got connection 1
[15:36:31.431] [Forwarding server 53048] Got connection 2
The connection hangs on [Forwarding server 53048] Got connection 2 for a few seconds before disconnecting me and repeating this message (and asking for password again). I tried removing the .vscode-server file from the linux computer, which is then recreated right away but it still doesn't let me connect. I also tried changing the timeout in the vscode settings but this also did nothing. I am unsure why this would happen after simply physically moving the computer from one place to another but remaining on the same vpn, and why I would still be able to connect with regular ssh but just not through the vscode-remote ssh extension.
You might try ssh manually to the server and delete the remote server folder which makes VSCode download it again from scratch.
This has helped me today:
rm -rf ~/.vscode-server/
rm -rf ~/.vscode-remote/
The suggestion comes from the following discussion: https://github.com/microsoft/vscode-remote-release/issues/2513
You might also wanna check if your new network IP is allowed in the target group of the server.
I had the same exact issue, and for me.
I dont have a resolution but a crappy workaround - reboot the far machine.
im running ubuntu 20.04 and once i rebooted, then i can connect from visual studio and connection stays up, BUT once i close the VSC and restart, then i see this issue again, and again i have to reboot the far machine.
EDIT: later i discovered that stopping the sshd daemon with systemctl start/stop sshd also helps this situation - so no need to reboot
This issue is due to a hard coded 20 second timeout in the protocol between the vscode client and the remote server. This is discussed in detail here: https://github.com/microsoft/vscode-remote-release/issues/7497. No fixes for this yet and will hopefully be fixed soon by making this timeout configurable (to allow overcoming these disconnects).

VSCode: Remote - SSH extension - nothing happens when trying to conncet to remote server

I have recently discovered vscode and the remote development extension, and wanting to try it out, but I can't get the damn thing to connect to my development server.
I've installed the both the vscode and vscode insiders packages by downloading the .deb packages manually on my local machine and installed the extension it self by executing this line:
ext install ms-vscode-remote.vscode-remote-extensionpack
Afterwards my pre-configured ssh hosts gets discovered fine and i have key-based auth running and it works fine when connecting to the server from a terminal.
But when I try to connect to the server, by right clicking and selecting one of the two options, only a notification saying "Confirming hostname is reachable" pops up for a second or two and then nothing else happens.
There are no information in the "output" view, other than this line:
remote-ssh#0.42.2
I've checked and confirmed the remote server has the needed prerequisites.
Also i see nothing in the /var/log/audit/audit.log on the remote server when trying to connect, so I dont even think it tries to establish a connection.
What am I missing ?
Local OS: Linux Mint 19 Tara
Remote OS: CentOS 7
I found the issue - "+" signs makes the extension fail: https://github.com/microsoft/vscode-remote-release/issues/612
I have this line in my local .ssh/config
Host *+*
ProxyCommand ssh $(echo %h | sed 's/+[^+]*$//;s/\([^+%%]*\)%%\([^+]*\)$/\2 -l \1/;s/:/ -p /') nc -q0 $(echo %h | sed 's/^.*+//;/:/!s/$/ %p/;s/:/ /')
Which allows me to connect to host b through host a like so:
ssh hosta+hostb
Removing that fixed the issue, and I connect succesfully to a remote host - it simple seems that that vscode dislikes that line.

Failed to parse remote port from server output: bash: no job control in this shell

I am trying to use VSCode - Insiders to run code on a docker container in a remote AWS machine using the Remote - SSH plugin. I have opened a terminal and set up port forwarding like so: ssh -L 2201:localhost:2222 user#host -N -i ~/.ssh/id_rsa. Then in VSCode I try to connect to root#localhost and it starts up, but then gives me an error message:
> Found existing installation...
> Found running server...
>
> bash: no job control in this shell
"install" terminal command done
Received install output: bash: no job control in this shell
Failed to parse remote port from server output: bash: no job control in this shell
I started doing this process a couple days ago and it worked. Yesterday it was in and out a bit, and today it's not working at all. I've tried turning it off and on again, but can't get it to work. In case it's relevant, I am on MacOS with the Mojave OS.
Edit:
Magically, it worked today (the following day) the first time. I would still be interested in knowing how to fix this next time it breaks. In case this helps, here's the output from when it is working:
SSH Resolver called for "ssh-remote+7b22686..."
SSH Resolver called for host: root#localhost
Setting up SSH remote "localhost"
Using commit id "473af338..." and quality "insider" for server
Using SSH config file "/Users/user/config"
Install and start server if needed
> Found existing installation...
> Found running server...
>
> bash: no job control in this shell
> 368805d0-03...==38466==
"install" terminal command done
Received install output: 368805d0-03...==38466==
Server is listening on port 38466
Using SSH config file "/Users/user/config"
Spawning tunnel with: ssh -F /Users/user/config root#localhost -N -L localhost:39003:localhost:38466
Spawned SSH tunnel between local port 39003 and remote port 38466
Waiting for ssh tunnel to be ready
Tunneling remote port 38466 to local port 39003
Resolving "ssh-remote+7b22686f737..." to "localhost:39003", attempt: 1
Edit 2: And now (the following following day) it's not working again.
Edit 3: I have a config file at ~/config. Here are the contents:
Host *
User root
Port 2201
IdentityFile ~/id_rsa
In the specific implementation shown above, you have User root in your config and are logging in with root#localhost, so you have your username twice. Leave the config file as is and just enter localhost in VSCode. This still doesn't solve the instability issue, but it does fix one problem.
I have the same issue when configuring my server. It solved by this issue. After save your config file for remote server, change the remote shell path like this issue, and then connect, you will in.
https://github.com/microsoft/vscode-remote-release/issues/220#issuecomment-490374437