How to install WSL on Windows 2019 server behind a corporate proxy
Posted on March 1, 2022 by Adrian Wyssmann ‐ 3 min read
At my current employer we have to use Windows Server virtual machines as development environments. For me as a Linux fanboy, this is not a very nice experience, hence why not use WSL?
Introduction
Sadly we have still Windows 2019 Servers, which only supports WSL1 since build 1709 and unfortunately not WSL2. Luckily we now have 1709 builds, so we can at least use WSL1. Also are we sitting behind a corporate proxy, so installation and configuration is slightly more difficult.
Installation
We also don’t have a Windows app store available, so we have to manually install WSL1 following the WSL Installation Guide
Open Powershell as an Administrator and run
Restart your Server
Download the Linux version of your choice We will download Ubuntu 20.04 for WSL1
Download has started, it can take 10 minutes to download the zip file
Extract the file
For ubuntu other steps are necessary and we have to further extract archives
On normal windows machines run:
Add-AppxPackage .\ubuntu2004.appx
After that you can start Ubuntu20.04 on Windows WSL1 and create your user
Fix common problems
Fix vim and nano text editor blank screen problem
If you get a blank screen when opening an editor or using screen, you are facing this issue and hence you have to do add the following to your ~/.bashrc
:
Fix vim and nano text editor blank screen problem
If you get permission errors when running screen in WSL1 you can add the following lines into your ~/.bashrc
Get Distro ready to work with your corporate environment
In order to work with the proxy and self-signed certificates there are some more steps necessary
Add corporate certificates
If you have self-signed corporate certificates, they have to be added to the trusts in your distro.
- Copy certificates to
/usr/local/share/ca-certificates/
(Ubuntu, Debian) or/usr/share/pki/trust/anchors/
(OpenSuse) - Run
sudo update-ca-certificates
orupdate-ca-certificates
depending of your distro
Configure package source
I assume - as we do - you use something like [Artifactory] as a repository proxy. So what is required
Ensure [Artifactory] can access the package repo. I don’t recommend to use the official url but directly pin one of the official mirrors.
If you use the official package url, you still don’t know which mirror Artifactory will pick. So, all possible mirrors have to be whitelisted so that Artifactory can access them. In our case we configured Artifactory to use http://pkg.adfinis.com/ubuntu/ as the remote url
Once this works, you can configure your distribution to use your [Artifactory]
Details may vary, depending on your distribution of choice, for OpenSuse it would be like this:
Configure Proxy
For certain activities you may be allowed to access the internet, hence, ensure you configure your proxy settings, by adding something like this to ~/.bashrc
Best Practices
There is a full list of WSL1 Best practices, however here are some which I find useful
To list all installed distributions
To list Linux distributions you can run:
Integrated Terminal in VS Code
You can configure that in the settings as follows:
Git
Git has to be configured so it uses the proxy for external repos and the credential manager