Do you want to do remote development on your WSL2 container in Visual Studio Code? Read this.
SSH to your Windows host (SSH Server must be installed in Windows Features)
ssh user@windowshostStart Powershell
powershellRun this command to switch SSH from CMD to WSL
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\WINDOWS\System32\bash.exe" -PropertyType String -ForceEdit .bashrc if you want set default shell other than bash (zsh) and add this code in ~/.bashrc
# Launch Zsh
if [ -t 1 ]; then
exec zsh
fi
Reference: https://www.howtogeek.com/258518/how-to-use-zsh-or-another-shell-in-windows-10/
ssh user@windowshostYou should now see WSL2 instead of CMD
At this point you can connect to your Win10 host with Remote SSH in VSCode with your Windows username and pw. But you'll actually start and connect to WSL2.
- Install the Remote - SSH extension
- Add a new SSH target and connect with your Windows host, username and password (you will automatically log in as the Linux user)
The workaround was inspired by: https://www.hanselman.com/blog/the-easy-way-how-to-ssh-into-bash-and-wsl2-on-windows-10-from-an-external-machine