'Clion and cmd ssh WSL are refused on windows 10
I've configured WSL for my computer, and it work in WSL terminal successfully.
zoom@Zoom:/etc/ssh$ ssh zoom@localhost -p 2222
zoom@localhost's password:
Welcome to Ubuntu 20.04 LTS (GNU/Linux 4.19.104-microsoft-standard x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue Jun 2 19:42:24 CST 2020
System load: 0.0 Processes: 16
Usage of /: 0.9% of 250.98GB Users logged in: 0
Memory usage: 1% IPv4 address for eth0: myIpAddress
Swap usage: 0%
0 updates can be installed immediately.
0 of these updates are security updates.
Last login: Tue Jun 2 19:33:21 2020 from 127.0.0.1
However, I can't ssh WSL with cmd or Clion.
CMD:
C:\Users\Zoom>ssh zoom@localhost -p 2222
ssh: connect to host localhost port 2222: Connection refused
Clion ssh
I get this error
Can't connect to remote host: Connection refused: connect
I have tried my best to search for a solution. But no solution works
this is some information on my sshd_config file:
ListenAddress 0.0.0.0
Port 2222
UsePrivilegeSeparation no
PasswordAuthentication yes
AllowUsers zoom
I realy want to know how to fix it.
My Windos version is 2004 (os build 19635.1).
WSL version is 2.
WSL system is ubuntu-20.04
Thanks very much!
Solution 1:[1]
Ok, I see the problem. The WSL2 is said to use a virtual machine. So the IP in WSL is different from that in Windows. You won't have this problem in WSL version 1. Unfortunately, this will change the IP address of the WSL every time you reboot. There are also some solutions but I can't understand, so I will put the link reference from someone blog in chinese: https://www.oyohyee.com/post/note_wsl2_net (I don't know if this blog can solve the problem, but it seems like it could) I found the official solution: https://devblogs.microsoft.com/commandline/whats-new-for-wsl-in-insiders-preview-build-18945/
Solution 2:[2]
In my case, after the configuration in the question description is done, restart the SSH service in WSL, and then restart the specific ubuntu distribution in WSL2 helps.
p.s.: Simply restart the computer doesn't work for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 |