DEV Community

serezlan
serezlan

Posted on

SSH into Ubuntu WSL in Windows

Overview

I love to work in linux, however there are times when I need to sneak into Windows for whatever reason. The thing is I work much faster in linux terminal and want to utilize WSL. Some articles I've found has rather complicated steps.
So here is simple steps to get you on your way.

Requirements

  • Windows with WSL installed. You may pick whatever distro you wish.
  • SSH server in your linux box.

Steps

Enable SSH server on linux box.

This step is may differ for each distro. Below is for debian based:

sudo systemctl  ssh start 
Enter fullscreen mode Exit fullscreen mode

Create tunnel from Ubuntu WSL into Linux host

ssh -R 2000:localhost:22 <your-linux-username>@<your-linux-host>
Enter fullscreen mode Exit fullscreen mode

[Optional] Copy public key to linux host

This will allow to do passwordless login. If you haven't create ssh key in your WSL, do the following:

  • ssh-keygen -t rsa
  • Copy the content of ~/.ssh/id-rsa.pub to ~/.ssh/authorized_keys file in your linux host

Drawback

This method require you to manually start tunnel from your Windows bash.

Summary

Ok, Thats all. Just couple few steps to get you SSH into your Windows box. You can also extend this to allow it to be accessible from the internet.
I hope you find this usefull.

Top comments (0)