VSCode: connecting from Linux to Windows

Recently, while working on the WPILib codebase, I found that my poor Linux laptop was not upgraded enough to do the heavy-lifting, as the codebase has pulled in a dependency on GLIBC 2.32 and I’m unwilling to risk my laptop upgrading from Ubuntu 20 to 22. Rather than give up, I shifted my development work to a Windows PC that I drive from my laptop.

I’ve used the SSH plugin for VSCode in the past and it’s a solution I’m fond of. Setting it up took just a few steps on the host machine and the client machine.

Host machine: install and configure SSH service

While modern Windows machines generally come with OpenSSH client preinstalled, the SSH service is an option and must be installed and configured manually. Steps were documented here; they are basically “Install the app and then configure the service to auto-start.”

Once I did that, I had to contend with the config options in Windows being a bit different from the Ubuntu defaults I’m used to. I set up an authorized_keys file in C:\Users\%USERNAME%\.ssh, but the file isn’t actually used until you edit C:\ProgramData\ssh\sshd_config to make the following changes:

  • Enable public key auth: PubkeyAuthentication yes
  • (for me) Disable password auth: PasswordAuthentication no
  • Because my Windows user is an admin, comment out the last two lines in the file, which start with Match Group administrators and AuthorizedKeysFile. These lines force Administration users to pull auth keys from the administrators_authorized_keys file instead of the personal files in their home directories.

Note that after changing the config file, you have to restart OpenSSH SSH Server using the Windows Services application.

Client machine: configure vscode to talk to Windows

After installing the Remote - SSH extension in vscode, a little configuration was needed to get the connection running.

VSCode has a known bug, mostly showing up in Windows 11, where the default config doesn’t mesh cleanly with the version of OpenSSL running on Windows these days. I had to mess with it a bit, but the solution turned out to be

  • Open the Settings UI in vscode
  • Search for useLocalServer
  • Disable the Remote.SSH: Use Local Server option.

Image of the option to disable in context

Once I did that, I was able to successfully connect to the remote machine with a command line and everything.