microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.66k stars 288 forks source link

Remoting SSH support for Alpine Linux #6347

Open Bit-Chaos opened 2 years ago

Bit-Chaos commented 2 years ago

Currently Alpine Linux is supported for WSL-Remoting only. It would be great seeing support for Alpine using SSH on remote machines so that development can be done on cloud-instances running MUSL-based distributions.

J-Siu commented 2 years ago

I was looking for this for a long time. However I found a way to use remote-ssh to a alpine vm recently. Following is what I did on the alpine(remote) box:

# This is what make vscode remote-ssh work
apk add gcompat libstdc++ curl git

# As alpine by default use busybox and some common utilities behave differently, like grep
apk add grep dropbear-scp dropbear-ssh

# Add zsh if using zsh shell
apk add zsh

The warning still show up, but work normally so far. I can verify docker extension works in this setup.

EzequielBruni commented 2 years ago
gcompat libstdc++ curl

THANK YOU! For ages, this just wouldn't work. Note that I made a couple of changes: I use openssh, and it works just fine. bash works too. Otherwise, everything is flawless with a properly set up .ssh/config file. I can now log into my LXD containers through a proxy tunnel flawlessly.

adamcstephens commented 2 years ago

Using the packages mentioned above, I'm able to make a remote SSH connection and almost everything works.

The only outstanding issues I encounter are :

  1. fails to find the installed git binary
[2022-05-22T21:58:33.014Z] Validating found git in: git
[2022-05-22T21:58:33.019Z] Git installation not found.
  1. displays an error on every warning.

I don't mind if this is ever officially supported, but fixing git and allowing me to disable the warning would make this a great solution for me.

J-Siu commented 2 years ago

I don't mind if this is ever officially supported, but fixing git and allowing me to disable the warning would make this a great solution for me.

Alpine always do minimal installation, so we have to install git ourselves. In the alpine box, as root:

apk add git
adamcstephens commented 2 years ago

Alpine always do minimal installation, so we have to install git ourselves. In the alpine box, as root:

apk add git

Yes, I have git installed. vscode cannot find or use it for some reason.

J-Siu commented 2 years ago

Alpine always do minimal installation, so we have to install git ourselves. In the alpine box, as root:

apk add git

Yes, I have git installed. vscode cannot find or use it for some reason.

In vscode setting, try:

"git.ignoreMissingGitWarning": true,
adamcstephens commented 2 years ago

In vscode setting, try:

"git.ignoreMissingGitWarning": true,

I already had this setting enabled. Ignoring the warning hides the popup but I want vscode to find the installed git so that the version control integrations work.

Is there any way to enable better debugging or troubleshoot the git not found failure?

screenshot_2022-05-23-190017

J-Siu commented 2 years ago

In vscode setting, try:

"git.ignoreMissingGitWarning": true,

I already had this setting enabled. Ignoring the warning hides the popup but I want vscode to find the installed git so that the version control integrations work.

Is there any way to enable better debugging or troubleshoot the git not found failure?

I remember spending hours hunting that down after posting here. Solved it but forgot to drop down notes. The cause is VS Code remote server(or the SCM extension) cannot get default environment on Alpine Linux, which include $PATH.

I dig through my alpine setup and updated my blog here: https://johnsiu.com/blog/alpine-vscode/#vs-code-and-alpine-git

PS: Regarding debugging, as long as ssh tunnel is working, log is located on the remote box: $HOME/.vscode-server/data/logs/<timestamp>/remoteagent.log. If ssh tunnel is not working, there maybe none or minimum.

adamcstephens commented 2 years ago

Ok, so hardcoding the git path as @J-Siu shows in their blog works. Adding to the remote settings JSON and reloading the window gives SCM functionality:

  "git.path": "/usr/bin/git"

It would still be better if VSCode could correctly read the path of the git binary from the environment. It's not as if /usr/bin is a non-standard location.

lamminhthien commented 2 years ago

I was looking for this for a long time. However I found a way to use remote-ssh to a alpine vm recently. Following is what I did on the alpine(remote) box:

# This is what make vscode remote-ssh work
apk add gcompat libstdc++ curl git

# As alpine by default use busybox and some common utilities behave differently, like grep
apk add grep dropbear-scp dropbear-ssh

# Add zsh if using zsh shell
apk add zsh

The warning still show up, but work normally so far. I can verify docker extension works in this setup.

Thanks you so much. But after install above package you need to config /etc/ssh/sshd_config and modifed from "#AllowTcpForwarding no" to AllowTcpForwarding yes

santicalcagno commented 2 years ago

Has anyone got remote containers working through an Alpine SSH host? I seem to have hit #6739 while trying.

[9103 ms] Host server: Error: spawn git ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
[9104 ms] Host server: (node:3273) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(Use `node --trace-warnings ...` to show where the warning was created)
[9106 ms] Host server: Error: spawn test ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
[9107 ms] Host server: (node:3273) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 2)
qaqland commented 2 years ago

I was looking for this for a long time. However I found a way to use remote-ssh to a alpine vm recently. Following is what I did on the alpine(remote) box:

# This is what make vscode remote-ssh work
apk add gcompat libstdc++ curl git

# As alpine by default use busybox and some common utilities behave differently, like grep
apk add grep dropbear-scp dropbear-ssh

# Add zsh if using zsh shell
apk add zsh

The warning still show up, but work normally so far. I can verify docker extension works in this setup.

Physical machine(on amd64) with Alpine Linux still does not work yet.

J-Siu commented 2 years ago

@santicalcagno Have you try all steps on my blog yet?: https://johnsiu.com/blog/alpine-vscode/#vs-code-and-alpine-git

One quick test is try to ssh to the alpine vm with ssh tunnel, if that doesn't work, then you need to update sshd config in alpine vm.

santicalcagno commented 2 years ago

@J-Siu yeah, unfortunately I still have those ENOENT errors after following your guide (thanks!). I tried tunneling via ssh -L and I see output on both sides of the connection while testing with nc, so that looks good. Maybe something else from the default config needs to be changed to make it work, but I dunno. At this point I went back to a non-Alpine VM, maybe I'll try again in a couple months.

FWIW, this is all on aarch64 (M1 mac running VSCode in macOS, SSH'ing to an aarch64 Alpine VM). The issue I linked made me suspicious of the VM arch playing a part in this, but I created an x64 Alpine VM and as far as I could test the issue still happens in my machine.

YAMLcase commented 1 year ago

1.74.0 introduced a new Remote Tunnels feature. I'm hoping this is something that can simplify connecting to a running container.

alexanderkiyanov commented 1 year ago

I had the same issue and I can't use VSCode with alpine linux VM. But I realized that I can use another VSCode extension for a remote ssh connection. And It works. The extension's called SSH FS.

qaqland commented 1 year ago
localhost:~$ code-cli --version
code-cli 1.75.0 (commit e2816fe719a4026ffa1ee0189dc89bdfdbafb164)

localhost:~$ uname -a
Linux localhost 5.15.89-0-lts #1-Alpine SMP Thu, 19 Jan 2023 08:07:26 +0000 x86_64 Linux

VSCode now can use Remote Tunnels to connect Alpine Linux installed on Physical machines.

But latency is a serious problem, and it would be nice to have a native SSH Remote method support.

soupdiver commented 1 year ago

I was looking for this for a long time. However I found a way to use remote-ssh to a alpine vm recently. Following is what I did on the alpine(remote) box:

# This is what make vscode remote-ssh work
apk add gcompat libstdc++ curl git

# As alpine by default use busybox and some common utilities behave differently, like grep
apk add grep dropbear-scp dropbear-ssh

# Add zsh if using zsh shell
apk add zsh

The warning still show up, but work normally so far. I can verify docker extension works in this setup.

This wasn'tenough for me. I also has to install bash to get the connection working.

mill1000 commented 8 months ago

Unfortunately with the latest remote requirements (glibc >=2.28, libstdc++ >= 3.4.25) it seems these packages aren't enough to run the remote server.

qaqland commented 8 months ago

Unfortunately with the latest remote requirements (glibc >=2.28, libstdc++ >= 3.4.25) it seems these packages aren't enough to run the remote server.

use 1.85.2 and disable auto update

mill1000 commented 8 months ago

They've backed down on the lastest GLIBC and LIBCXX requirements for another 12 months. I haven't tested yet, but updating to 1.86.1 would probably allow SSH remote to Alpine with the above mentioned packages.

fmillion-mnsu commented 7 months ago

@mill1000 Yes, I confirm on Alpine 3.19 and on latest code 1.86.1 you can connect to an Alpine server with the gcompat, libstdc++ and bash packages installed as a minimum. You do get an ugly non-dismissable unspported OS banner though.

I hope that before the year is up that we get some sort of official support on the server side for musl-based distros. I have Alpine running on most of my servers and cloud instances. VS Code already supports alpine inside of dev containers, so it would appear most of what needs to be working already does. (Perhaps there's a way to fool the code server into thinking it's in a dev container or something?)

wfleischer commented 6 months ago

After the recent update I had to install the GNU ps tool, too. So here's my setup:

apk add bash procps gcompat libstdc++ curl git

Then configure the VSCode Server to find the git tool:

mkdir -p /root/.vscode-server/data/Machine
cat > /root/.vscode-server/data/Machine/settings.json <<EOF
{
    "git.path": "/usr/bin/git"
}
EOF
qaqland commented 6 months ago

not procps but procps-ng

apk add procps-ng

update: vscode now has special alpine build and only needs apk add bash curl git libstdc++ procps-ng