天天看點

linux伺服器防止任何人使用su指令成為root使用者

指定隻有某個使用者才可以使用su指令到root使用者

實作方法:

1.vi /etc/pam.d/su

打開注釋

# auth required pam_wheel.so use_uid

echo "SU_WHEEL_ONLY yes" >> /etc/login.defs

2.usermod  -G 10 lndy   //把lndy使用者加入到wheel組

[root@localhost ~]# id landy

uid=500(lndy) gid=500(lndy) groups=500(lndy),10(wheel) context=root:system_r:unconfined_t:SystemLow-SystemHigh

[root@localhost ~]# id xxl

uid=501(xl) gid=501(xl) groups=501(xl) context=root:system_r:unconfined_t:SystemLow-SystemHigh

lndy使用者可以su到root,而xl使用者不可以su到root

[lndy@localhost ~]$ su -

Password: 

[xl@localhost ~]$ su -

su: incorrect password

本文轉自 xxl714 51CTO部落格,原文連結:http://blog.51cto.com/dreamgirl1314/1392642,如需轉載請自行聯系原作者

繼續閱讀