Closed back-2-95 closed 3 years ago
Tested using Windows 10 Professional, WSL2 with Ubuntu 18.04.
In Ubuntu terminal
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential
cd ~/stonehenge
make up
rootCA.pem
file in your ~/stonehenge/certs
foldercd ~/stonehenge/certs
explorer.exe .
You now have a Windows Explorer window open for the certs-folder. Copy its path from the address bar.
Manage user certificates
.Your Windows environment now trusts the certificate that the initial make up -command created on the WSL2 side.
Install your dev site at this stage
In Windows
192.168.1.101 site.docker.sh
ISSUES
For dev work, VS Code with its WSL - Remote plugin works wonders.
When in Ubuntu terminal, type code .
to open your current folder in VS Code on the Windows side.
Type explorer.exe .
in the terminal to open your current folder in the Windows file browser.
Tested with Windows 10 Professional with Debian 10.6
Settings -> Resources -> WSL Intregration
In WSL terminal
sudo apt update && sudo apt upgrade && sudo apt install build-essential
~/.ssh/
ssh -T git@github.com
. You should get, e.g. Hi {YOURNAME}! You've successfully authenticated, but GitHub does not provide shell access.
cd ~/stonehenge
make up
DNS configuration
Powershell
terminal and run command: Get-DnsClientServerAddress
Interface Index
Ethernet
and with wireless it's Wi-Fi
Interface Index
, run this command:
Powershell
terminal as an administrator for this command!Set-DnsClientServerAddress -InterfaceIndex {YOUR INTERFACE INDEX NUMBER} -ServerAddresses ("127.0.0.48","1.1.1.1")
ipconfig -flushdns
If stonehenge can't connect to docker socket, just restart it.
@j-vee and @shamalainen
Could you check this PR https://github.com/druidfi/stonehenge/pull/43/ and check the new documentation.
I'd like to have certainty of the following:
If there is anything we can automate further, that would be nice.
The commands look good to me.
Though the doco is missing the section where the rootCA.pem
generated by stonehenge gets added to the Windows User Certificates so that you don't get SSL Certificate Errors when viewing the sites on Windows side. So a section before DNS Configuration like
Install stonehenge as per the readme
Open your Stonehenge directory cd ~/stonehenge
Run make up
You now have rootCA.pem
file in your ~/stonehenge/certs
folder
cd ~/stonehenge/certs
explorer.exe .
You now have a Windows Explorer window open for the certs-folder. Copy its path from the address bar.
Open Manage user certificates
.
Open Action
-> All tasks
-> Import
In the dialog that opens up, select Next
, Browse
and then paste the path from above to the address bar and select the rootCA.pem
file for import.
In the next step, select the Certification Store
to be Trusted Root Certification Authorities
and Save.
Your Windows environment now trusts the certificate that the initial make up
-command created on the WSL2 side.
@shamalainen did you have https and certs working?
@back-2-95 Currently I have it not working. I need to tell the browser that the site is safe etc. everytime.
@back-2-95 @j-vee I had issues adding the certificate via the GUI, so I did it via Powershell (as an admin).
So after You now have a Windows Explorer window open for the certs-folder. Copy its path from the address bar.
I opened Powershell
as an admin and ran this command:
Import-Certificate -Filepath '{THE PATH YOU COPIED}' -CertStoreLocation cert:\CurrentUser\Root
,
e.g. my path was Import-Certificate -Filepath '\\wsl$\Work\home\coder\stonehenge\certs\rootCA.pem' -CertStoreLocation cert:\CurrentUser\Root
where my username is coder
and WSL2 machine name is Work
EDIT 1:
This command worked for me, I had to replace CurrentUser
with LocalMachine
.
Import-Certificate -Filepath '{THE PATH YOU COPIED}' -CertStoreLocation cert:\LocalMachine\Root
.
EDIT 2:
I got it working through the GUI as well, but had to add Root certificates to LocalComputer instead of CurrentUser.
I have now tested your stuff @j-vee and @shamalainen. DNS stuff worked as did the Import-Certificate.
And here is something I put together: https://github.com/druidfi/stonehenge/blob/3e9e7d0a757a35e5b3092a5f20dd779b88455d28/WSL2.md
The oneliner is still WiP but I checked that it really run the code. You can see the script here: https://github.com/druidfi/stonehenge/blob/3e9e7d0a757a35e5b3092a5f20dd779b88455d28/install.ps1
Certificate importing is now automated as I was able to detect WSL name and user so I can create the path to cert. No need to use explorer to copy it. I just hope that \\wsl$\WSL_NAME\home\WSL_USER\stonehenge\certs\rootCA.pem
is valid in all WSL distros we want to support.
DNS configuration is still with those manual steps. I cannot find automated solution for that. Basically you need to add that nameserver IP for selected index which might be different for everyone.
Update: as we're nearing removal of resolver, WSL2 usage will also be easier. Stay tuned.
@j-vee you reported that new resolverless version works fine with WSL2 - could you check if the PR #49 is close to truth?
@back-2-95 Yup! Looks good to me. I tested most of the manual commands out just now and they all worked fine.
mkcert
is used in Windows 10, no need it to be installed with Stonehengemkcert
is installed to Windows with ChocolateyWSL_DISTRO_NAME=Ubuntu-20.04
can be used to detect WSL2 Ubuntumake
to be installeddocker-compose.yml
setup