vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

Remoting SSH support for Alpine Linux

Open Bit-Chaos opened this issue 3 years ago • 24 comments

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.

Bit-Chaos avatar Feb 14 '22 19:02 Bit-Chaos

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 10 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

vscode-triage-bot avatar Feb 15 '22 17:02 vscode-triage-bot

:slightly_smiling_face: This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

vscode-triage-bot avatar Mar 06 '22 02:03 vscode-triage-bot

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.

J-Siu avatar Mar 25 '22 21:03 J-Siu

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.

EzequielBruni avatar Mar 28 '22 03:03 EzequielBruni

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.

adamcstephens avatar May 22 '22 22:05 adamcstephens

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

J-Siu avatar May 23 '22 04:05 J-Siu

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.

adamcstephens avatar May 23 '22 12:05 adamcstephens

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,

J-Siu avatar May 23 '22 21:05 J-Siu

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

adamcstephens avatar May 23 '22 23:05 adamcstephens

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.

J-Siu avatar May 24 '22 09:05 J-Siu

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.

adamcstephens avatar May 24 '22 20:05 adamcstephens

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

lamminhthien avatar Jul 01 '22 00:07 lamminhthien

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)

santicalcagno avatar Sep 10 '22 14:09 santicalcagno

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.

qaqland avatar Sep 13 '22 03:09 qaqland

@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.

J-Siu avatar Sep 16 '22 15:09 J-Siu

@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.

santicalcagno avatar Sep 18 '22 19:09 santicalcagno

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

YAMLcase avatar Dec 14 '22 20:12 YAMLcase

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.

alexanderkiyanov avatar Jan 20 '23 14:01 alexanderkiyanov

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.

qaqland avatar Feb 04 '23 05:02 qaqland

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.

soupdiver avatar Apr 27 '23 08:04 soupdiver

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.

mill1000 avatar Feb 08 '24 02:02 mill1000

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

qaqland avatar Feb 08 '24 03:02 qaqland

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.

mill1000 avatar Feb 09 '24 17:02 mill1000

@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?)

fmillion-mnsu avatar Mar 09 '24 18:03 fmillion-mnsu

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

wfleischer avatar Apr 11 '24 12:04 wfleischer

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

qaqland avatar Apr 22 '24 03:04 qaqland