KotaiCode logo

SSH to WSL from terminal emulator

Dr. Sandeep Sadanandan — February 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

Nginx Ingress Expires in March 2026 — Migrate to Gateway API with Envoy Gateway

Full setup with TLS (cert-manager), wildcard domains, automatic DNS (ExternalDNS), and real-world debugging

Tom Jose — February 3, 2026

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

Cronochat is a simple, powerful Slack app.

Tom Jose — March 22, 2025

Paper: Integrating Sensor Data, Analysis, and Routing for Urban Systems

Turning urban sensor data into actionable insights and routing capabilities through a scalable analysis platform

Julian Jöris — March 6, 2026