How to start Openssh server after install in WSL?

I'm trying run the command ssh localhost but receive the error

ssh: connect to host localhost port 22: Connection refused

WhenI try to check the status of the SSH Server with the command sudo service ssh status I receive the error

  • sshd is not running

I installed the SSH Client with sudo apt-get install openssh-client and the SSH Server with sudo apt-get install openssh-server ii. What else could the issue be thank you.

2

2 Answers

WSL does not automatically start sshd

Try removing the ssh server with:

sudo apt remove openssh-server

And then install it again with:

sudo apt install openssh-server

Then check the server status to see if it is running. If not, try:

sudo service ssh start

to start the server. See more here

Hope this helps

wsl 2 now supports crontab
Add this to your crontab

@reboot sudo service ssh start

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like