1、增加一個redhat用戶
[root@station66 ~]# useradd redhat [root@station66 ~]# echo redhat |passwd --stdin redhat Changing password for user redhat. passwd: all authentication tokens updated successfully. |
2、將用戶增加到wheel組,大家知道wheel組和staff是嘎哈的麼?我也是聽別人說的,http://forums.macnn.com/90/mac-os-x/108958/group-permissions-wheel-vs-staff-whats/
爲什麼需要 wheel 組?
通常在UNIX下,即使我們是系統的管理員,也不推薦用 root 用戶登錄來進行系統管理。一般情況下用普通用戶登錄,在需要 root 權限執行一些操作時,再 su 登錄成爲 root 用戶。但是,任何人只要知道了 root 的密碼,就都可以通過 su 命令來登錄爲 root 用戶——這無疑爲系統帶來了安全隱患。所以,將普通用戶加入到 wheel 組,被加入的這個普通用戶就成了管理員組內的用戶,但如果不對一些相關的配置文件進行配置,這個管理員組內的用戶與普通用戶也沒什麼區別——就像警察下班後,沒有帶槍、穿這便衣和普通人(用戶)一樣,雖然他的的確確是警察。
對於服務器來說,我們希望的是剝奪被加入到 wheel 組用戶以外的普通用戶通過 su 命令來登錄爲 root 的機會(即只有屬於 wheel 組的用戶纔可以用 su 登錄爲 root)。這樣就進一步增強了系統的安全性。
[root@station66 ~]# usermod -a -G wheel redhat #將用戶加入到wheel這個附加組裏. |
3、讓redhat用戶提升爲管理員
[root@station66 ~]# vim /etc/pam.d/su #編輯pam認證文件 #%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. # uncomment the following line 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@station66 ~]# vim /etc/aliases |
結果所有普通用戶在終端、和ssh方式都無法登陸系統了,報錯信息如下:
Jul 26 21:11:53 station66 init: tty (/dev/tty1) main process (2274) terminated with status 1 Jul 26 21:11:53 station66 init: tty (/dev/tty1) main process ended, respawning |
經過排查發現了是selinux問題導致的,關閉了就解決了。
[test2@station66 ~]$ su - root #大家發現test2用戶先在就不能su root了,redhat用戶不能被su了 Password: su: incorrect password [test2@station66 ~]$ su - redhat Password: su: incorrect password [test2@station66 ~]$ [redhat@station66 ~]$ su - root #redhat用戶su root是可以的,增加了系統的安全性。 Password: [root@station66 ~]# |
參考鏈接: