How to setup SSH server on your WSL 2 Ubuntu for remote-logins.
This is to log down my new setup of a Windows 11 desktop with WSL 2 (Ubuntu 20.04). The goal is to be able to ssh to the WSL from my other computers in the local network. There are indeed multiple ways of doing so, this time I decided to make it as simple as possble.
Run a powershell with admin right, check the installation status of both the ssh client and server:
Highly likely the client is installed by default while the server is not.
Now install the server:
Set it to start automatically in the future:
And also start it right now:
Now we can test if the connection work by something like:
from another computer.
If it works it will give us a Windows shell. We can run wsl
from there to prompt the Ubuntu bash. Or even lazier, by setting the default ssh login shell to the Ubuntu bash:
This approach does not require setting up the ssh server on Ubuntu since it is the Windows host machine that is handling the SSH connection.
That’s neat.
Why Windows 11? Because now it by default supports WSL with GPU passthrough. And I have a RTX 2080Ti now ready for things beyond gaming. :)
If you see mistakes or want to suggest changes, please create an issue on the source repository.