Xshell连接wsl2下的Ubuntu

卸载ssh,再安装ssh

sudo apt-get remove --purge openssh-server   ## 先删ssh
sudo apt-get install openssh-server          ## 在安装ssh  
sudo rm /etc/ssh/ssh_config                  
sudo service ssh --full-restart

修改配置文件

sudo vim /etc/ssh/sshd_config

更改以下配置项

Port 6666
ListenAddress 0.0.0.0
PasswordAuthentication yes
PermitRootLogin yes
sudo service ssh --full-restart   ## 每次电脑重启都得执行这个命令
sudo dpkg-reconfigure openssh-server

给wsl设置root密码

sudo passwd root

连接xshell

主机号设置为127.0.0.1,端口号设为刚刚设置的6666,即可连接

posted @ 2023-10-23 15:17  请务必优秀  阅读(286)  评论(0编辑  收藏  举报