Skip to content

Instantly share code, notes, and snippets.

@mateuszkwiatkowski
Last active March 13, 2025 18:31
Show Gist options
  • Save mateuszkwiatkowski/ce486d692b4cb18afc2c8c68dcfe8602 to your computer and use it in GitHub Desktop.
Save mateuszkwiatkowski/ce486d692b4cb18afc2c8c68dcfe8602 to your computer and use it in GitHub Desktop.
Configure FreeBSD to work with VScode's remote ssh extension

This procedure was tested on FreeBSD-CURRENT build from d8819d88af52.

  1. Enable linuxulator and install linux userland:

    # sysrc linux_enable="YES"
    # service linux start
    # pkg install linux_base-c7
    

    Test it:

    $ /compat/linux/usr/bin/uname -a
    Linux monster-1 4.4.0 FreeBSD 14.0-CURRENT #1 main-n254392-d8819d88af52: Wed Apr  6 22 x86_64 x86_64 x86_64 GNU/Linux
    

    For more details on linuxulator setup please refer to handbook.

  2. remote-ssh seem to ignore bash config files so we need to change $PATH in /etc/login.conf or send custom env with SetEnv directive in ssh_config. Choose which fits you better.

    Confiugure /etc/login.conf

    By default it's class default, we need to give priority to linux binaries: :path=/compat/linux/usr/sbin /compat/linux/usr/bin /sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin ~/bin:\ rebuild CAP database: cap_mkdb /etc/login.conf

    Or add this to your ssh config (~/.ssh/config)

    Host your-freebsd.box
      SetEnv PATH="/compat/linux/usr/sbin:/compat/linux/usr/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
    
  3. Set you normal PATH for your every day use in your shell's config file (.bashrc od .zshrc, etc)

  4. Connect to your FreeBSD box with VScode's remote SSH extension!

@morganwdavis
Copy link

morganwdavis commented Mar 13, 2025

@fsackur I'm running Version 1.98.2 (latest release as of now) using the steps described here in VS Code Server and Remote SSH on FreeBSD with remote.SSH.useExecServer enabled and no issues. Also, all extensions are up to date, notably Remote - SSH.

$ uname -a
FreeBSD dtl-08 14.2-RELEASE-p1 FreeBSD 14.2-RELEASE-p1 GENERIC amd64
$ pkg info | grep linux
linux-rl9-libsigsegv-2.13_1    Handling page faults in user mode (Rocky Linux 9.4)
linux_base-rl9-9.5_3           Base set of packages needed in Linux mode (Rocky Linux 9.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment