用root用户登录有太多的弊端,因为权限太大,可能一不小心删错了文件,带来严重的后果。禁止root用户登录,从某种意义上说,也有利于服务器安全。
出于安全方面的考虑,先增加一个普通权限的用户,再使用su命令切换到root用户。
1. 创建普通权限的用户,用户名为 yunwei123.com
# useradd yunwei123.com
2. 为yunwei123.com用户设置密码
# passwd yunwei123.com
Changing password for user yunwei123.com.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
3. 修改sshd_config文件如下
# vi /etc/ssh/sshd_config
#PermitRootLogin yes
修改如下
PermitRootLogin no
4. 重启ssh服务
# /etc/init.d/sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
登陆方法为用上面创建的普通用户登录。如果想使用root用户,使用su命令切换到root用户。