Skip to content

Windows Subsystem for Linux

Introduction

What is the Windows Subsystem for Linux?

Windows Subsystem for Linux (WSL) is a feature of Windows that allows you to run a Linux environment on your Windows machine, without the need for a separate virtual machine or dual booting. WSL is designed to provide a seamless and productive experience for developers who want to use both Windows and Linux at the same time.

(source)

Installation

Tutorials

Concepts

Configuration

VPN

To make WSL compatible with Cisco AnyConnect VPN, enable mirrored mode networking and DNS tunneling by adding the following to .wslconfig within the %USERPROFILE% directory:

%USERPROFILE%\.wslconfig
[wsl2]
networkingMode=mirrored
dnsTunneling=true

Learn more about networkingMode and dnsTunneling here.

Note

networkingMode=mirrored and dnsTunneling=true require Windows 11 version 22H2 or higher.

VS Code

Here we configure VS Code to use the SSH binary provided by WSL, along with the aforementioned SSH config, to have a single SSH config shared by WSL and VS Code.

First, install VS Code for your user (not system-wide). When prompted to Select Additional Tasks during installation, be sure to check the Add to PATH option so you can easily open a folder in WSL using the code command. Also, install the Remote Development extension pack.

Create a Windows batch file to passthrough SSH invocations to the WSL-provided SSH:

%USERPROFILE%\.ssh\ssh.bat
C:\Windows\system32\wsl.exe ssh %*

Add the following to VS Code's settings.json within the %APPDATA%\Code\User directory:

%APPDATA%\Code\User\settings.json
{
    "remote.SSH.path": "C:\\Users\\manselmi\\.ssh\\ssh.bat(1)",
    "remote.SSH.remotePlatform": {
        "jump": "linux",
        "vps": "linux"
    },
    "security.allowedUNCHosts": ["wsl$", "wsl.localhost"]
}
  1. Replace with the expansion of %USERPROFILE%\.ssh\ssh.bat for your user, escaping backslashes as shown here.

Start or restart VS Code. Click the blue Remote Development icon in the lower-left corner, then click Connect Current Window to Host….

Type the name of a SSH host alias defined in the SSH config file, such as jump, then press Enter.

VS Code will then connect and launch a remote session. If you were to select the TERMINAL tab, VS Code would launch a remote shell session.

Learn more about VS Code Remote Development.