Do you want to do remote development on your WSL2 container in Visual Studio Code? Read this.
Installation Documentation - https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse
Default allows password authenication, suggest turning it off and using Public Key auth.
See this for debugging help -- depending on the user you want to use it with, you might need to use a different authorized_keys file (there is one for admin and one for standard users) https://serverfault.com/questions/873064/public-key-authentication-windows-port-of-openssh
SSH to your Windows host
ssh user@windowshost
Start Powershell
powershell
Run 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 -Force
ssh user@windowshost
You 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