SSH to WSL from terminal emulator

Dr. Sandeep SadanandanFebruary 4, 2020

Image

So, you have setup WSL ( Windows Subsystem for Linux) and are not happy with the “built in”emulator. In my case, I wanted to use an emulator and ssh to the Ubuntu in wsl2.

I hit a few road blocks, but here’s how one could get around them.

Install ssh

sudo apt install openssl openssh-server```

Windows will ask you whether you want to allow ssh through the firewall. Say yes.

#### Fix the configuration

Open the configuration file at `/etc/ssh/sshd_config` and do the following.

1. Change the port from `22` to `2222`. (or another one of your choice)
1. (optional) Make `key` authentication to `no` and password auth to `yes`

PubkeyAuthentication no
PasswordAuthentication yes```

Only if you haven’t setup the keys

Start the server

sudo service ssh --full-restart```

You might see that the (ssh) keys are missing, like below

Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key```

If so, create the keys like below

Create the keys

ssh-keygen -A```

And restart the server once more (see above)

#### Good to go

Go to the terminal of your choice, and `ssh` to localhost.

ssh -p 2222 user@localhost```

It’ll ask for the password, and might be a bit slow to let you in.

Be patient, you will be rewarded.

Cheers, Sandeep.

About the author

Dr. Sandeep Sadanandan

Dr. Sandeep Sadanandan

With two decades of experience, Sandeep brings onboard both theoretical and practical knowledge from a wide range of projects. Your ideas will blossom into wonderful products in his hands.

We have other interesting reads

Setting up Gitlab Runner on Amazon EKS: A Step-by-Step Guide

In the ever-evolving landscape of software development, Continuous Integration and Continuous Delivery (CI/CD) have become indispensable practices.

Tom JoseFebruary 27, 2024

Achieving Resilience: High Availability Strategies in Kubernetes

In cloud computing, it’s important to keep services running smoothly, even when maintenance tasks like updating or restarting nodes are necessary.

Tom JoseJune 14, 2024

Conversational Finance: AI Assistant that talks to your Fund Data

We have been working with VC funds and taxation for sometime, and we thought it is high time we had a new way for fund managers and tax specialists to interact with financial data — naturally, securely, and instantly.

Dr. Sandeep SadanandanNovember 24, 2025