標籤:art 安裝 cat code uid roo openssl su - ati
通常情況下,一般使用者通過運行“su -”命令、輸入正確的rootpassword。能夠登入狀態root使用者來對系統進行管理員層級的配置。
可是。為了更進一步加強系統的安全性,有必要建立一個管理員的 組,僅僅同意這個組的使用者來運行“su -”命令登入狀態root使用者。而讓其它組的使用者即使運行“su -”、輸入了正確的rootpassword,也無法登入狀態root使用者。在UNIX和Linux下。這個組的名稱通常為“wheel”。
一、禁止非whell組使用者切換到root
1、 改動/etc/pam.d/su配置
[[email protected] ~]# vi /etc/pam.d/su ← 開啟這個設定檔#auth required /lib/security/$ISA/pam_wheel.so use_uid ← 找到此行,去掉行首的“#”
2、 改動/etc/login.defs檔案
[[email protected] ~]# echo “SU_WHEEL_ONLY yes” >> /etc/login.defs ← 加入語句到行末以上操作完畢後,能夠再建立一個新使用者。然後用這個建立的使用者測試會發現,沒有加入到wheel組的使用者,運行“su -”命令。即使輸入了正確的rootpassword,也無法登入狀態root使用者
3、 加入一個使用者woo,測試能否夠切換到root
[[email protected] ~]# useradd woo[[email protected] ~]# passwd wooChanging password for user woo.New UNIX password: BAD PASSWORD: it is WAY too shortRetype new UNIX password: passwd: all authentication tokens updated successfull
4、通過woo使用者登入嘗試切換到root
[[email protected] ~]$ su - root ← 即使密碼輸入正確也無法切換Password: su: incorrect password[[email protected] ~]$
5: 把root使用者增加wheel組再嘗試切換,能夠切換
[[email protected] ~]# usermod -G wheel woo ← 將普通使用者woo加在Administrator 群組wheel組中[[email protected] ~]# su - woo[[email protected] ~]$ su - root ← 這時候我們看到是能夠切換了 Password: [[email protected] ~]#
二、加入使用者到管理員,禁止普通使用者su到root
6、加入使用者,並加入Administrator 群組。禁止普通使用者su到root。以配合之後安裝OpenSSH/OpenSSL提升遠端管理安全
[[email protected] ~]# useradd admin[[email protected] ~]# passwd adminChanging password for user admin.New UNIX password: BAD PASSWORD: it is too shortRetype new UNIX password: passwd: all authentication tokens updated successfully.[[email protected] ~]# usermod -G wheel admin (usermod -G wheel admin 或 usermod -G10 admin(10是wheel組的ID號))[[email protected] ~]# su - admin[[email protected] ~]$ su - rootPassword: [[email protected] ~]#
方法一:wheel組也可指定為其他組。編輯/etc/pam.d/su加入例如以下兩行
[[email protected] ~]# vi /etc/pam.d/suauth sufficient /lib/security/pam_rootok.so debugauth required /lib/security/pam_wheel.so group=wheel
方法二:編輯/etc/pam.d/su將例如以下行#符號去掉
[[email protected] ~]# vi /etc/pam.d/su#RedHat#auth required /lib/security/$ISA/pam_wheel.so use_uid ← 找到此行。去掉行首的“#”#CentOS5#auth required pam_wheel.so use_uid ← 找到此行,去掉行首的“#”
#儲存退出就可以============
[[email protected] ~]# echo "SU_WHEEL_ONLY yes" >> /etc/login.defs ← 加入語句到行末
(實際測試這步操作可省略)
Linux禁止非WHEEL使用者使用SU命令