一、新建的虚拟机使用的Ubuntu系统,设置固定ip之后,互相ping都正常,在使用Xshell连接发现无法连接,如下异常:
原因:未安装openssh-server
解决方案:sudo apt install openssh-server
再次使用xshell连接,发现能使用除root外的其他账户正常连接。
二、解决xshell无法使用root连接问题
1、虚拟机安装完成后,首先用普通账户登录进去,然后更改root账户的密码,使用sudo passwd命令:
root@ubuntu:~# sudo passwd
Enter new UNIX password:
Retype new UNIX password:
2、之后从普通账户切换到root账户登录状态:
root2@ubuntu:~$ su root
Password:
root@ubuntu:/home/root2# cd
root@ubuntu:~#
3、解决root无法连接
修改 /etc/ssh/sshd_config 文件:
root@ubuntu:~# vi /etc/ssh/sshd_config
修改完后保存并退出。重启服务:
root@ubuntu:~# /etc/init.d/ssh restart
成功重启服务后。就可以在Xshell中使用root账户连接了。