前言:不知是我机器还是MS故意,一路坑,简单记录:
安装openssh-server (有可能不需要做)
sudo apt-get update
sudo apt-get install openssh-server
启动
直接启动会报一系列ssh的key找不到的错误
john@HP303:~$ sudo service ssh restart
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
需要如下方式生成
sudo ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key
sudo ssh-keygen -t ed25519 -b 256 -f /etc/ssh/ssh_host_ed25519_key
sudo ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key
sudo ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_root_rsa_key
此时,即可完成启动:
john@HP303:/etc/ssh$ sudo service ssh restart
* Restarting OpenBSD Secure Shell server sshd
打开22端口及设置密码登录:
因为安全原因,WSL并没有开放22端口及设置密码登录,可以打开配置文件:sudo vim /etc/ssh/sshd_config
,做如下配置:
Port 22
PasswordAuthentication yes
重新启动
sudo service ssh restart
此时,即可从任意联网电脑登录到WSL中!!!
网友评论