VPS开启root用户登录SSH

如果预设只能用密钥登录VPS,则可以进行以下操作。

1.切换到root:

sudo -i

2.修改SSH配置文件/etc/ssh/sshd_config

nano /etc/ssh/sshd_config

3.修改PermitRootLogin和PasswordAuthentication为yes

# Authentication:
PermitRootLogin yes //默认为no,需要开启root用户访问改为yes
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes //默认为no,改为yes开启密码登陆

4.设置root密码

passwd root

5.重启SSH

(1)debian系:

/etc/init.d/ssh restart

(2)centos系:

systemctl restart sshd.service

最后更新于