BUG:WSL 的 ssh server 无法启动

BUG

使用 sudo service ssh start 启动 ssh 服务,提示:

 * 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:

PS C:\Users\suyua> ssh ryan@localhost
ssh: connect to host localhost port 22: Connection refused

FIX

卸载重装 openssh-server:

sudo apt-get purge openssh-server  # purge 是卸载并删除配置文件
sudo apt-get install openssh-server

然后修改 /etc/ssh/sshd_config 的下列几行参数:

#Port 22   # 如果端口冲突,就需要修改这个
ListenAddress localhost  # 只接受本地请求
PasswordAuthentication yes  # 允许密码登录

重启 ssh 服务:

sudo service ssh restart

然后连接:

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

......

问题解决。

参考

-windows-wsl sshd配置

转载于:https://www.cnblogs.com/kirito-c/p/10979570.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值