Solved Connecting to FreeBSD from VS Code over SSH

Hi guys,

I'm trying to figure out how to connect to my FreeBSD box from VS Code over SSH. There are some instructions here and here, but I haven't had much luck following those.

Client
Pop!_OS (based on Ubuntu 22.04)
VS Code 1.95.0
  • VS Code extension Remote - SSH v0.116.2024102915 (pre-release)
  • Remote.SSH: Enable Remote Command is enabled.
  • ~/.ssh/config:
    Code:
    Host beastie1
      Hostname beastie1
      User jiri
      RemoteCommand /compat/linux/usr/bin/bash
Server
FreeBSD 14.1
  • linux service is running
    Code:
    # service -e | grep linux
    linux/etc/rc.d/linux
  • Code:
    /compat/linux/usr/bin/uname -a
    Linux beastie1 5.15.0 FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC x86_64 x86_64 x86_64 GNU/Linux
  • VS Code creates ~/.vscode-server dir (empty) on first attempt to connect.

Remote - SSH extension output (truncated):

Code:
[13:01:34.946] stderr> Authenticated to beastie1 ([192.168.0.161]:22) using "publickey".
[13:01:35.001] > ready: 0f751ff52673
[13:01:35.009] > FreeBSD 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC
[13:01:35.009] Platform: linux
[13:01:35.015] > /usr/local/bin/zsh
[13:01:35.015] Parent Shell: zsh
[13:01:35.015] Parent Shell pid: 122712
[13:01:35.021] > 3128
[13:01:35.021] Waiting for pid of spawned 'sh' subshell: '3128'...
[13:01:35.038] > 0f751ff52673: running
> Script executing under PID: 3128
[13:01:35.045] > Unsupported platform: FreeBSD

My primary shell on the server is zsh, but it shouldn't be an issue, because I'm explicitly telling VS Code to use /compat/linux/usr/bin/bash.

Any ideas?
 
Thanks for the mention! Glad you got it working with some tweaking.
Oh, thank you for the tutorial! And I love that the admins approved the thread even though I had already answered it before they did.

Maybe one more detail for people stumbling upon this in the future: the extension's Remote.SSH: Enable Remote Command option doesn't seem to be doing anything, I've turned it off just to see what happens, and it still works.
 
I have followed the instructions and the link above, but still had the `unsupported platform: FreeBSD` error. I did a little bit of research and realized that the VScode has `Enable Remote Command` option. I enabled it and all of my problems are solved. Here's my notes, maybe it will help someone in the future:

Bash:
# First, install the VSCode - OSS package on FreeBSD
pkg install vscode
# Enable Linux support for FreeBSD in /etc/rc.conf, or simply use:
sysrc linux_enable="YES"
# Start the Linux service:
service linux start
# Install the required packages for the subsystem:
pkg install linux-rl9-libsigsegv
# To check if Linux is installed successfully, run:
/compat/linux/usr/bin/bash --version

# In the client, enable the `Enable Remote Command` option.
# Then apply your SSH configurations to the ~/.ssh/config file.
# For example, I have the following configuration:
Host my-delusional-host
    HostName 127.0.0.1
    Port 2223
    User root
    RequestTTY force
    RemoteCommand /compat/linux/usr/bin/bash
# The RemoteCommand is mandatory (thanks to Jiri), others are optional.
 
Thanks. Now it almost works now, but fails to open a directory.
Code:
uname -a
FreeBSD repeater 14.3-RELEASE FreeBSD 14.3-RELEASE releng/14.3-n271432-8c9ce319fef7 GENERIC amd64
On FreeBSD execute.
Code:
pkg install emulators/linux_base-rl9
# then
sysrc linux_enable="YES"
service linux start
On MacOS, add to ~/.ssh/config
Code:
Host Repeater-BSD
  HostName repeater.local
  User rpt
  RequestTTY force
  RemoteCommand /compat/linux/usr/bin/bash
and enable VSCode Settings for Remote.SSH: Enable Remote Command.

The FreeBSD console displays.
Code:
linux jid 0 pid 2567 (tokio-runtime-w): syscall pid_open not implemented
Jul 13 17:00:07 repeater sshd-session[2584]: error: PAM: Authentication error for rpt from 192.168.1.35

/etc/rc/conf is as follows.
Code:
hostname="repeater"
ifconfig_igc0="DHCP"
sshd_enable="YES"
ntpd_enable="YES"
moused_nondefault_enable="NO"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
zfs_enable="YES"
mdnsd_enable="YES"
mdnsd_flags="igc0"
linux_enable="YES"

Clearly, a step is missing - but what?
 
Last edited:
The future has arrived with a fresh install of 14.3
Code:
No packages available to install matching 'linux-rl9-libsigsegv' have been found in the repositories.
Any ideas?

Thanks for the note. I will update the guide soon.

As for the other issue, I can't help much as the approach in the guide worked well on Linux locally to FreeBSD remote.
 
Thanks for the note. I will update the guide soon.

As for the other issue, I can't help much as the approach in the guide worked well on Linux locally to FreeBSD remote.
Done. I also noticed an issue if sh is the default user shell and noted it down.
 
Back
Top