Xshell连接wsl2下的Ubuntu

发布时间 2023-10-23 15:21:25作者: 请务必优秀

卸载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,即可连接