Alpine Linux and VS Code Remote SSH
How to do it in 2022.
Have been trying to do VS Code remote ssh to alpine box for years. The connection always failed with following error:
The remote host may not meet VS Code Server’s prerequisites for glibc and libstdc++
A few month ago I finally seat down and went through VS Code logs on both ends. The first thing I notice was Alpine box didn’t install
curl by default, and VS Code server need at least one of them. Installing
wget solved half the problem and I got more logs.
Then I hit on the actual
libstdc++ was solved by a simple
apk add. And after some googling, it turned out Alpine had a
gcompat package that provides glibc function on top of
musl. Installing it and VS Code remote ssh start working.
So it turned out to make VS Code remote ssh to Alpine box is as simple as running following on the Alpine box:
You can replace
wget. And aside from that, VS Code is also looking for
I had the above discovery post in vscode-remote-release back in Mar. But the story didn’t end there.
dropbear is an OpenSSH alternative for ssh server and client. It is simpler and smaller. If you don’t need ssh tunnel, sftp/scp to and from the Alpine box, you can just stick with it.
However I was having issues with ssh tunneling, sftp/scp, etc. On the Alpine box, I end up switching out
dropbear and back to
openssh server and client.
Unlike Ubuntu, following need to be set manually for
sshd on Alpine.
VS Code and Alpine Git
Though Alpine Linux git install in
/usr/bin/git, same location as most other Linux and Mac OS, VS Code cannot load the default environment and has to be set manually.
Connect VS Code to the Alpine box, then in settings, open the remote tab(
Remote [SSH: <hostname>]):
Click upper right icon to open json file, and put following:
Git will start working after reconnect.
busybox is another brilliant package that replaces lot of common linux commands with a single binary.
However, if you are doing lot of shell scripting and rely on some “standard” command line options and/or output, you are likely to run into issue.
I installed following in my Alpine box:
Turn out the steps required are not difficult and hope VS Code will one day support ssh-ing to Alpine out of the box.