使用 sudo service ssh start
启动 ssh 服务,提示:shell
* Restarting OpenBSD Secure Shell server sshd 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 [ OK ]
而后使用 powershell 链接,提示 refused:ubuntu
PS C:\Users\suyua> ssh ryan@localhost ssh: connect to host localhost port 22: Connection refused
卸载重装 openssh-server:windows
sudo apt-get purge openssh-server # purge 是卸载并删除配置文件 sudo apt-get install openssh-server
而后修改 /etc/ssh/sshd_config
的下列几行参数:ssh
#Port 22 # 若是端口冲突,就须要修改这个 ListenAddress localhost # 只接受本地请求 PasswordAuthentication yes # 容许密码登陆
重启 ssh 服务:.net
sudo service ssh restart
而后链接:rest
PS C:\Users\suyua> ssh ryan@localhost ryan@localhost's password: Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.4.0-17763-Microsoft x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage ......
问题解决。code
-windows-wsl sshd配置server