Preskoči na sadržaj

How to run Visual Studio (VS) Code Remote over SSH on FreeBSD 13 and 14

FreeBSD Ports provide editors/vscode with the latest stable version of Visual Studio Code and the FreeBSD Foundation provides an excellent guide how to install and use it. Unfortunately, the latest stable version of Visual Studio Code Remote - SSH still does not officially support FreeBSD, but only Linux, Windows, and macOS.

Until recently, it was possible to use Linuxulator and CentOS 7 (emulators/linux_base-c7 in Ports) to run it successfully, but this is not possible anymore since early February, when version 1.86 updated minimum glibc version requirement to 2.28 and glibcxx to 3.42.5, which implies CentOS 8 or newer.

Recent effort by Gleb Popov and Dima Panov (sponsored by Serenity Cybersecurity, LLC) brought Rocky Linux 9 to Linuxulator. It is now again possible (and quite simple) to run Visual Studio Code Remote - SSH on FreeBSD's currently supported releases 13.2-RELEASE, 13.3-RELEASE, 14.0-RELEASE, and 14.1-RELEASE.

Let's start with enabling Linuxulator and installing the required packages:

% doas sysrc linux_enable="YES"
% doas service linux start
% doas pkg install linux-rl9-libsigsegv

Note that installing devel/linux-rl9-libsigsegv will automatically pull emulators/linux_base-rl9 as a dependancy. After installing it, we should make sure that Linuxulator works correctly (using uname) and check that bash also got installed successfully:

% /compat/linux/usr/bin/uname -a
Linux gaser 5.15.0 FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC x86_64 x86_64 x86_64 GNU/Linux
% /compat/linux/usr/bin/bash --version
GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

On the client side, you should adjust OpenSSH's config file to use Linuxulator's bash, for example:

$ cat ~/.ssh/config
    RemoteCommand /compat/linux/usr/bin/bash

And that's it! Upon the first connection, the VS Code Remote server will be installed. Afterward, you can add your favorite extensions, as you would do it on Linux, Windows, or macOS.