On Win10, in WSL 2 running Ubuntu 20, I've installed sshd running on a port different from 22, namely 2222. To the firewall I've added an incoming rule for TCP port 2222.
From the windows command prompt, ssh -p 2222 127.0.0.1 works. So does ssh -p 2222 xxx.xxx.xxx.xxx, to the dotted quad reported by WSL's ifconfig.
From the windows command prompt (not WSL), ipconfig reports 192.168.1.yyy, its address on my router. Through that address, Windows reaches and is reached by other 192.168.1 hosts on that router (Windows, Mac, Linux; ping, http, mounting disks, ssh only from WSL).
From the windows command prompt, ssh -p 2222 192.168.1.yyy fails with Connection refused. How can I make that work?
PuTTY 0.74 behaves the same as the windows command prompt's ssh.
ssh -v -v -vadds possibly useful diagnostics:
debug1: Connecting to 192.168.1.100 [192.168.1.yyy] port 2222.
debug3: finish_connect - ERROR: async io completed with error: 10061, io:000002E243EDC460
debug1: connect to address 192.168.1.yyy port 2222: Connection refused
If in sshd_config I restrict ListenAddress to
192.168.1.yyy:2222, then the other incoming ssh's fail as expected. So what needs configuring may be not ssh but WSL itself.ifconfig -adoesn't mention any 192.168's.Context: this is a stepping stone to enable ssh into WSL from the router's other hosts. For now WSL's /etc/ssh/sshd_config uses PasswordAuthentication; I'll later change that to PubKeyAuthentication.