Centos5 下对root用户的安全考虑
之前写了不少偏向搭建服务的日志,对于方面很少提及,在接下来的学习中, 将会多多的考虑linux和unix!先啰嗦下,下面的设置只针对linux系统,FreeBSD系统默认下都已经设置好了,由此可见,BSD设 计者对安全的考虑还是比较全面的。
centos系统在默认情况下,所有shell环境不为flase和 nologin的系统,都可以使用SSH方式登录系统,而我们通常不希望也能使用这样的方式进行登陆,尽管SSH采用了KEY文件加密。
login as: root
password:
Last login: Sun Feb 1 00:26:18 2009
[root@centos5 ~]# vi /etc/ssh/sshd_config 修改SSH配置文件如下:
PermitRootLogin no (不允许root用户直接SSH登陆)
PermitEmptyPasswords no (不允许空密码登陆)
PasswordAuthentication yes (使用密码进行验证,如果此项为no,则表示只能使用key文件验证SSH登陆)
这样以后就无法使用root用户直接SSH登陆了
login as: root
password:
Access denied (系统提示拒绝访问)
默认情况下,所有登录用户只要在输入SU命令后,输入正确的root用户密码,就能切换 到root用户,因而我们必须对SU命令做出限制
[root@centos5 ~]# useradd yang 新建一用户并设置密码如下:
[root@centos5 ~]# passwd yang
Changing password for user yang.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
login as: yang
password:
Last login: Sun Feb 1 00:35:04 2009 from 192.168.0.1
[yang@centos5 ~]$ su -
Password: (输入正确的密码后yang用户就能顺利的切换成root用户)
[root@centos5 ~]# cat /etc/pam.d/su
#%PAM-1.0
auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
auth required pam_wheel.so use_uid (将本段前面的注释号去掉)
auth include system-auth
account sufficient pam_succeed_if.so uid = 0 use_uid quiet
account include system-auth
password include system-auth
session include system-auth
session optional pam_xauth.so
[root@centos5 ~]# exit
[yang@centos5 ~]$ su -
Password:
su: incorrect password
(输入root用户密码后,系统提示不正确的密码,其实真正的原因是yang用户不是wheel组的成员,这样以后需要管理员权限的用户只要加入到
这个组就可以使用SU命令进行切换了!)
[root@centos5 ~]# cat /etc/group |grep wheel (通过编辑/etc/group文件将yang用户添加到wheel组)
wheel:x:10:root,yang
- 最新评论