最近想要测试 Debian 包,就在服务器上搭建了一个 Ubuntu18.04 的虚拟机。搭好虚拟机之后通过 ssh 登陆 root 用户,居然被拒绝了。。。
试了三次密码后报错:
Permission denied (publickey,password).
第一反应是密码记错了,然后跑去 web 页面远程登陆 root 用户,密码正常使用。试了一下普通用户 ssh 登陆,可以登录,估计是禁用了 root 。
Google 一下,果然,说是 出于安全预防措施,ssh 禁止 root 登陆,脑壳疼。
瞄了一眼 ssh 的配置文件,在 /etc/ssh/sshd_config 文件中找到了一行:
#PermitRootLogin prohibit-password
root 登陆被禁止了,把这行的注释去掉,然后把 prohibit-password 改成 yes。
重启 ssh 服务器
$ sudo systemd restart sshd
重新使用 root 进行 ssh 连接,O 了。
最后还是要吐槽一下 Ubuntu,默认没有安装 ssh,新做的系统一定要创建一个普通用户才能修改 root 的密码,还不能直接用 root 进行 ssh 登陆。。。
个人使用 Ubuntu 不错,但服务器感觉还是 centos 好用一点。