linux-禁止root登录

为提高服务器安全性,通常都会禁止root登录

1、添加普通用户dwchensenwen并设置密码

useradd dwchensenwen

echo "csw930328@"|passwd dwchensenwen --stdin

usermod -a -G wheel dwchensenwen

vim /etc/sudoers

此时dwchensenwen普通用户就可以切换到root用户下

2、编辑/etc/ssh/sshd_config

vim /etc/ssh/sshd_config

修改PermitRootLogin yes为PermitRootLogin no

重启sshd服务

systemctl restart sshd

原文地址:https://www.cnblogs.com/mustark/p/11103718.html