ubuntu server 开启root密码登录

由 Jefsky 发布于 2024-01-04

ubuntu server 16.04 开启root密码登录
由于众多VPS默认使用证书验证登录,虽然安全但使用十分不便,所以特提供开启root用户并使用密码登录方法。

root账户设置密码
$ sudo passwd root

进入root账户
$ su root

编辑sshd_config文件
$ vi /etc/ssh/sshd_config
做如下修改:

1.允许root账户登录
PermitRootLogin without-password
~修改为~
PermitRootLogin yes

2.允许密码登录
PasswordAuthentication no
~修改为~
PasswordAuthentication yes

3.关闭证书验证登录(::确认可以使用密码登录后再做此修改,避免发生无法登录服务器的验证后果::)
UsePAM yes
~修改为~
UsePAM no

重启sshd服务
$ sudo service ssh restart