Remote editing over ssh to windows server - visual-studio-code

Remote SSH plugin states VS Code Insiders has experimental support for Windows 10/Server 1803+ using the official OpenSSH server.
I have the official OpenSSH server installed and configured on Windows Server 2019 1809. I can connect via pubkey authentication and have PowerShell Core over ssh working as well. I tried both Remote SSH and Remote SSH nightly plugin. At first it was complaining that it couldn't find bash. So I installed git bash and added it to the system path. I get the following error when attempting to connect to my windows server:
[16:02:41.398] Log Level: 3
[16:02:41.399] remote-ssh-nightly#2019.12.24000
[16:02:41.399] darwin x64
[16:02:41.401] SSH Resolver called for "ssh-remote+myserver", attempt 1
[16:02:41.401] SSH Resolver called for host: myserver
[16:02:41.401] Setting up SSH remote "myserver"
[16:02:41.413] Using commit id "e74405d11443c5361c31e2bc341866d146eee206" and quality "insider" for server
[16:02:41.414] Testing ssh with ssh -V
[16:02:41.425] ssh exited with code: 0
[16:02:41.425] Got stderr from ssh: OpenSSH_7.9p1, LibreSSL 2.7.3
[16:02:41.430] Running script with connection command: ssh -T -D 51951 -o ConnectTimeout=15 myserver bash
[16:02:41.430] Install and start server if needed
[16:02:43.451] > 5122b1a5b835: running
> Unsupported architecture: MINGW64_NT-10.0-17763 x86_64
> 5122b1a5b835##27##
[16:02:43.452] Got some output, clearing connection timeout
[16:02:43.710] "install" terminal command done
[16:02:43.710] Install terminal quit with output: 5122b1a5b835##27##
[16:02:43.710] Received install output: 5122b1a5b835##27##
[16:02:43.710] Unsupported architecture
[16:02:43.711] Resolver error: The remote host's architecture is not supported
[16:02:43.714] ------
Anybody know the magic sauce to get Remote SSH working w/ Windows 10/Server?

Looks like VSCode is attempting to run bash on the server which I'm guessing would resolve to git's bash which is mingw based as I recall. VSCode should be running Powershell on the server.
Did you include your server in the list of windows remotes in the extension's settings?

Requires "remote.SSH.windowsRemotes" setting. Here is the documentation.
"remote.SSH.windowsRemotes": ["myserver"]

Related

Podman isn't working in Remote Containers in Windows?

Any hints on why Remote - Containers isn't working with podman on Windows?
Installed podman v4.2.0 on Windows 11 via .msi package
Set remote.containers.dockerPath to podman in VS Code Settings
Run podman machine init
Run podman machine start
Open Remote Explorer in VS Code and be presented with the following:
Everything is working with podman — pull, run, images, etc, but Remote - Containers on VSCode doesn't recognize podman.
After running Remote-Containers Developer: Show All Logs... in VS Code:
[2022-08-21T12:55:15.916Z] Start: Run: podman version --format {{.Server.APIVersion}}
[2022-08-21T12:55:16.080Z] Stop (164 ms): Run: podman version --format {{.Server.APIVersion}}
[2022-08-21T12:55:16.080Z] Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM
Error: unable to connect to Podman. failed to create sshClient: dial unix \\.\pipe\openssh-ssh-agent: connect: No connection could be made because the target machine actively refused it.
And podman system connection list in a terminal:
Name URI Identity Default
podman-machine-default ssh://user#localhost:62078/run/user/1000/podman/podman.sock C:\Users\Edmundo\.ssh\podman-machine-default true
podman-machine-default-root ssh://root#localhost:62078/run/podman/podman.sock C:\Users\Edmundo\.ssh\podman-machine-default false
Related Issues: #6957, #6747.
Please confirm you are running the latest build (prerelease)
v0.236.1.
(there are known issues on github with earlier release, fixed in this version)
in a WSL shell, i.e. for debugging try this
first - try to start podman podlib REST api (for socket, lifetime 5000 sec. - set to zero for "forever")
podman system service -t 5000 &
then symlink the podman.sock to the location vscode expects:
sudo ln -s /mnt/wslg/runtime-dir/podman/podman.sock /var/run/docker.sock
if none of that works, would you mind posting a dump:
podman info
HINT: check the podman info YAML output for host | remoteSocket | path & make sure it matches the path /mnt/wslg/runtime-dir/podman/podman.sock above.
The bug being tracked on GitHub. One step you should also do is enable Run in WSL in VS Code Development Container extension settings. Then it will run the podman commands in the podman-machine-default wsl instance.

[VsCode Remote SSH]How to solve 'Could not establish connection to XXX.XXX.XXX.XXX: Downloading VS Code Server failed'?

[Problem Description]
When I work on setting VS Code remote ssh on a new server, I find this error:
"Could not establish connection to "XXX.XXX.XXX.XXX":Downloading VS Code Server failed - please install either curl or wget on the remote".
However, I have curl and wget installed on my remote server. And the network connection on my remote server is also fine. Following some tutorials in the web, I download vscode-server on the remote side by:
wget vscode-server-linux-x64.tar.gz https://update.code.visualstudio.com/commit:<commit-id>/server-linux-x64/stable
and then extract it, copy to ~/.vscode-server/bin/<commit-id>/, and replaced the files there.The error message disappears.
It works fine at the beginning, but everytime I close and reopen project on the remote server, VsCode would start to download remote server automatically and then collapse to so called "please install either curl or wget on the remote". Moreover, the VsCode built-in terminal would fail to no cuda environement or GPU driver error(Cuda and driver work fine on remote side) even if I fortunately connect to remote at chance.
[Environment]
Local Side:
MacOS Big Sur 11.2.3 + VsCode 1.50.1 + Remote-SSH Extension(Microsoft) 0.6.1
Remote Side
Ubuntu 18.04.5 + Wget 1.19.4 + Curl 7.58.0
[Log]
[10:57:03.119] Neither curl nor wget is installed - can't download the Server
[10:57:03.125] Resolver error: Error: Downloading VS Code Server failed - please install either curl or wget on the remote.
at Function.ServerInstallError (/Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:1:82253)
at /Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:1:79401
at Object.t.handleInstallOutput (/Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:1:80935)
at I (/Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:127:107056)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async /Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:127:104971
at async Object.t.withShowDetailsEvent (/Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:127:110308)
at async Object.t.resolve (/Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:127:108372)
at async /Users/XXX/.vscode/extensions/ms-vscode-remote.remote-ssh-0.61.0/out/extension.js:127:129627
[10:57:03.131] ------
[10:57:03.428] "install" terminal command done
[10:57:03.429] Install terminal quit with output:
This may be because there are so many vscodes open on the remote server that you need to kill all the VSCODE processes on the remote server and then try to connect again or make a new connection, save host information.

VScode SSH extension stuck on the installation step

For the past few months, I've used this VSCode Extension to work remotely on a linux server via SSH. I'll occasionally have a connection problem, but sshing from a terminal and deleting ~/.vscode-server/ has always fixed it. This time, though, that didn't fix it. I've tried deleting the folder multiple times, I've removed and reinstalled the VSCode extension, restarting my computer, everything I could think of. But each time, it gets stuck at downloading with wget, even if I leave it going for hours. I can connect to the server by sshing directly just fine, and other people I know can connect to the server through the extension as well. Is there anything else I can try to get this working?
Here's the full installation log (with the host name censored):
[19:17:22.756] Log Level: 2
[19:17:22.758] remote-ssh#0.56.0
[19:17:22.758] win32 x64
[19:17:22.759] SSH Resolver called for "ssh-remote+my.host.name", attempt 1
[19:17:22.759] SSH Resolver called for host: my.host.name
[19:17:22.760] Setting up SSH remote "my.host.name"
[19:17:22.776] Using commit id "e5a624b788d92b8d34d1392e4c4d9789406efe8f" and quality "stable" for server
[19:17:22.777] Install and start server if needed
[19:17:22.800] Checking ssh with "ssh -V"
[19:17:22.831] > OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
[19:17:22.836] Running script with connection command: ssh -T -D 52457 my.host.name bash
[19:17:22.838] Terminal shell path: C:\WINDOWS\System32\cmd.exe
[19:17:22.889] >
>
>
> ]0;C:\WINDOWS\System32\cmd.exe
[19:17:22.889] Got some output, clearing connection timeout
[19:17:22.898] >
>
>
>
[19:17:23.334] > 23b0d284345c: running
>
[19:17:23.363] > Acquiring lock on /path/to/home/.vscode-server/bin/e5a624b78
> 8d92b8d34d1392e4c4d9789406efe8f/vscode-remote-lock.my_username.e5a624b788d92b8d34
> d1392e4c4d9789406efe8f
>
[19:17:23.373] > Installing to /path/to/home/.vscode-server/bin/e5a624b788d92
> b8d34d1392e4c4d9789406efe8f...
> 23b0d284345c%%1%%
>
[19:17:23.381] > Downloading with wget
>
[19:17:27.721] > 23b0d284345c: running
> Acquiring lock on /path/to/home/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/vscode-remote-lock.my_username.e5a624b788d92b8d34d1392e4c4d9789406efe8f
> Installing to /path/to/home/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f...
> 23b0d284345c%%1%%
> Downloading with wget
>
I ended up getting it working. I was connecting to a Centos7 server, what worked for me was deleting ~/.wget-hsts. After that, it reinstalled the server and connected fine.
There are a few reports of a similar issue in the microsoft/vscode-remote-release project which implements for VSCode this feature.
For instance, issue 4008
The remote OS I am connecting to is a RHEL 7 Linux machine.
I tried fiddling with iptables and ports for the wget request to no avail.
It hangs for a little while at the wget step, and ultimately fails to connect. I tried tweaking just about every SSH setting in the remote.
The only other thing I noticed that might be related was with the Ports Available text at the bottom of the screen. It never reads anything other than 0 during the connection process. When I'm properly connected, it says 1 Port Available.
However, I did find a successful workaround: I rolled back the Remote SSH extension to 0.55.0 and it worked like a charm again.
So try and downgrade the Remote SSH extension, to see if it works.
I tried waiting for around 10 minutes and it downloaded. Don't know why although ✨

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