Transcript for:
Guide to Setting Up OpenSSH on WSL

what's up I'm troubleshoot and welcome back to another video in this quick guide I'll be taking you through setting up and using openssh as a server on Ubuntu WSL but this will work for a lot of other Debian based WSL operating systems essentially SSH is a remote terminal that we can use to connect to our WSL virtual machine and control it when you open up WSL it pretty much is already an SSH session it's just a shell but if you'd like to access it outside of your computer and the internet you'll need to create a specific SSH server in order to set up and use it anyways without further Ado let's go ahead and begin I'll go ahead and start by opening up Ubuntu WSL which brings up a brand new terminal on my system where we can go ahead and type in some commands there become Ubuntu is now awake we'll start by installing the SSH 7 sudo app install open SSH hyphen server then hit enter enter your pseudo password yes and wait for the open SSH server to be installed now we can sudo Nano Etsy SSH sshd underscore config to change the configuration of our server we can change the report here for example to 2000 scrolling down below we can use public key authentication Etc but we'll get back here later control s to save and control X to close now we'll need to automatically start up the SSH server when we start Ubuntu WSL with a recent update to Ubuntu WSL system D is enabled meaning we can get it to automatically start up or whenever the Ubuntu system starts to do this run sudo system CTL enable SSH and sudo system CTL status SSH to find out if it's running then we just need to enable it will sudo Nano Etsy wsl.conf and inside of you we need to make sure that inside of brackets boot the next line system D equals true controller has to save control X to close now we need to restart our Ubuntu WSL I'll open a new tab WSL hyphen hyphen is shut down to close it then we'll go ahead and restart it so Ubuntu WSL and now sudo systemctl enable SSH password and sudum system CTL status SSH and we should see that it's running now obviously if you're going to forward this to outside of your local PC it's a good idea to pick a port in different 222 and when you're ready you can allow it through the firewall some with this command in the description down below you can enable a firewall rule giving access to the openssh server in here but I already have an SSH server running on windows so I won't be running that unless I change the port anyways if you'd like to change it use sudo Nano Etsy SSH sshd underscore config in here we can customize different things including the port for example this however is ignored with Ubuntu 2210 and above just because ssht is changed the rest of these commands should still have effect it's just the port that should not artwork and the listen address for that Madam now in order to change the port that he uses we need to run a few different commands first of all we need to make a configuration file here now into sudo Nano Etsy systemd system ssh.socket.d listen.conf and paste in the same controller is to save control X to close then we need to reload the Daemon pseudo system CTL Daemon reload and pseudo systemctl to restart SSH now when we suit up system CTL status SSH you should see that it's now running on Port 2200. cool that was a bit of a workaround but at least we got there now if we go ahead and shut down this operating system with WSL shutdown it should close will the reopen Ubuntu him and shortly after it boots you should see sudo systems CTL status SSH password that was the wrong password then it's still running on Port 2200 cool let's go ahead and connect to it for example I'll use Visual Studio code using the remote SSH plugin I'll configure localhosts and we'll add a new Option here for Ubuntu WSL we can then connect to it so so remote SSH connect to host and Linux continue enter the password and just like that we should now be connected to it which we are let's go to files open folder and let's open just the root directory with Slash as such OK and password once more now we can navigate our Ubuntu WSL computer Ctrl J we can Neo fetch for example and you can see that it's running on techno PC Ubuntu Luna Lobster and if we run Neo fetch here for example you'll see it's the same things just a little bit slower anyways now we have it running at this point you can run that aforementioned firewall command to allow it through the firewall and connect to it outside of this computer anyways that's about it so thank you all for watching mine's been troubleshoot and I'll see you all next time ciao foreign