VSCode 1.99 以降でも CentOS 7.9.2009 へ Remote SSH する

手順

WSL2 などで sysroot をビルド

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
curl -sSLo .config 'https://raw.githubusercontent.com/microsoft/vscode-linux-build-agent/9199d1b6de24fdfb40de2a83dff95f48161d8d68/x86_64-gcc-8.5.0-glibc-2.28.config' && sed -i 's/4\.19\.287/3.10/' .config &&
cat <<'EOS' > Dockerfile && docker build -t ctng:1 . && docker run --rm -it -v "$PWD":/workdir -u ubuntu --name ctng ctng:1 bash -c 'cd /workdir && ct-ng build' && tar -C x86_64-linux-gnu/x86_64-linux-gnu -czf sysroot.tgz sysroot
FROM ubuntu:latest

RUN apt-get update
RUN apt-get install -y gcc g++ gperf bison flex texinfo help2man make libncurses5-dev \
python3-dev autoconf automake libtool libtool-bin gawk wget bzip2 xz-utils unzip \
patch rsync meson ninja-build

# Install crosstool-ng
RUN wget http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.26.0.tar.bz2
RUN tar -xjf crosstool-ng-1.26.0.tar.bz2
RUN cd crosstool-ng-1.26.0 && ./configure --prefix=/crosstool-ng-1.26.0/out && make && make install
ENV PATH=$PATH:/crosstool-ng-1.26.0/out/bin
EOS

CentOS 7 へ sysroot.tgz をコピーした上でインストール

1
2
mkdir -p /opt/vscode-sysroot && tar -C /opt/vscode-sysroot --strip-components 1 -xzf sysroot.tgz
curl -sSLo patchelf.tgz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-x86_64.tar.gz && tar -xzf patchelf.tgz && install -m 0755 bin/patchelf /usr/local/bin/vscode-patchelf

CentOS 7 の /etc/environment に以下を追記

1
2
3
VSCODE_SERVER_CUSTOM_GLIBC_LINKER=/opt/vscode-sysroot/lib64/ld-linux-x86-64.so.2
VSCODE_SERVER_CUSTOM_GLIBC_PATH=/opt/vscode-sysroot/lib64
VSCODE_SERVER_PATCHELF_PATH=/usr/local/bin/vscode-patchelf

以上で接続できるはず

使ってみる

GitHub Copilot が使える

開いているワークスペースについて Copilot に質問してみると、正しい答えが返ってくる

課題

拡張機能をインストールできない

画面右下に “Signature verification failed with ‘UnknownError’ error” と出ている

標準 C++ ライブラリが古いらしい

1
2
3
4
5
6
[kamasaki@vbox vsce-sign]$ pwd
/home/kamasaki/.vscode-server/cli/servers/Stable-6f17636121051a53c88d3e605c491d22af2ba755/server/node_modules/@vscode/vsce-sign
[kamasaki@vbox vsce-sign]$ bin/vsce-sign 
bin/vsce-sign: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by bin/vsce-sign)
bin/vsce-sign: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by bin/vsce-sign)
[kamasaki@vbox test]$

参考

https://code.visualstudio.com/docs/remote/faq#_can-i-run-vs-code-server-on-older-linux-distributions
https://hep.techwp.net/2025/04/16/remote-ssh-to-old-linux-servers-with-latest-vscode/
https://github.com/microsoft/vscode/issues/246375#issuecomment-2883034221

Hugo で構築されています。
テーマ StackJimmy によって設計されています。