Linux下只允许特定用户Su到Root
对于服务器来说,安全永远都是放在首位的,今天记录下只允许特定用户ssh到服务器,这样子可以防止某些人对你的服务器扫密码.禁止root ssh登录,只能让这个普通用户su到root,下面看操作
系统centos5
新建用户test,并设置密码
# useradd test
# passwd test
加入wheel组
# usermod -G wheel test
编辑pam的su设置
#vi /etc/pam.d/su
去掉auth required pam_wheel.so use_uid 的#注释
在密码策略里进行设置,追加参数到文件末尾
# echo "SU_WHEEL_ONLY yes" >> /etc/login.defs
禁止root登录
#vi /etc/ssh/sshd_config
PermitRootLogin no (把后面的yes改为no)
重启sshd服务,
#services sshd restart
退出root,可以验证下,使用root登录失败,使用test登录su到root,OK!
--------------------------
另外一种方法看着很方便,但是wesley还没有试验,可以借鉴下
只能允许单个用户登录
编辑/etc/ssh/sshd_config
AllowUsers sshuser1 sshuser2
只能允许某个组登录
AllowGroups sshgroup