xshell连接ubantu时,出现Connection closing...Socket close,connection closed by foreign host

明明是刚下好的ubantu,明明是按教程安装的软件,却出现了下面的错误xshell连接ubantu时,出现Connection closing...Socket close,connection closed by foreign host_第1张图片在网上搜了很久的解决办法,无奈有相同的问题,却没有一样的解决办法,终于,我探索出了自己的解决办法,所以整理一下,共享

如果你的ubantu在sudo service ssh restart命令后,也出现了下图的问题
在这里插入图片描述
那么,此办法应该可以解决你的问题
首先,输入sudo dpkg-reconfigure openssh-server
即可生成缺少的三个key,用ls -al /etc/ssh/ssh_*key
可以看到
xshell连接ubantu时,出现Connection closing...Socket close,connection closed by foreign host_第2张图片现在,在xshell中连接ubantu,发现Connection closing…Socket close,connection closed by foreign host问题已经解决,但出现了下面的问题xshell连接ubantu时,出现Connection closing...Socket close,connection closed by foreign host_第3张图片
这时就需要修改sshd.config文件了
1.输入sudo vim /etc/ssh/sshd_config,打开sshd_config文件
2.单击‘i’切换到编辑模式
3.将PermitRootLogin Prohibit-password改为PermitRootLogin yes,并去掉注释‘#’号
4.将PasswordAuthentication no改为PasswordAuthentication yes
5.单击‘Esc’退出,输入:wq进行保存并退出
6.最后输入sudo service ssh restart
xshell连接ubantu时,出现Connection closing...Socket close,connection closed by foreign host_第4张图片
这样就可以去xshell输入密码啦~刚才灰色的password会变成黑色,可以输入密码,
输入的密码就是ubantu的password
连接成功,welcome to ubantu!xshell连接ubantu时,出现Connection closing...Socket close,connection closed by foreign host_第5张图片
希望可以帮到你,有问题欢迎私信
(感谢,上面有张图的作者)

你可能感兴趣的:(xshell连接ubantu时,出现Connection closing...Socket close,connection closed by foreign host)