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

Introducing Cronochat: Supercharge Your Slack with Recurring, Scheduled, Broadcast, and Anonymous…

Cronochat is a simple, powerful Slack app.

Tom JoseMarch 22, 2025

From Proof-of-Concept to Production: Evolving Your Self-Healing Infrastructure

In the previous article, we explored building a self-healing nginx infrastructure using KAgent and KHook, covering autonomous configuration validation, intelligent analysis, and automated remediation.

Maryam NaveedDecember 4, 2025

Why Most Side Projects Fail — and How to Build One Like a Real Product

Most side projects start the same way.

Maryam NaveedAugust 22, 2025