限制su配置
關于限制su命令檢查項,對于大多數的Linux(Redhat系列、Debian系列),進行本項檢查很簡單。只需要檢查/etc/pam.d/su中是否配置了:
auth required pam_wheel.so use_uid [group=用戶組名]
有些資料講說需要有如下兩條配置:
auth sufficient pam_rootok.so
和 auth? required pam_wheel.so use_uid
這里要說明一下auth sufficient pam_rootok.so的作用,只需要執行man pam_rootok即可。其實從rootok這么一個名字就能看出來:pam_rootok - Gain only root access。也就是說對root不做限制:root可以任意切換到所有用戶。這一條是系統默認配置。檢查的時候并不做硬性要求。
不同Linux發行版區別
前面為啥要強調“大多數的Linux(Redhat系列、Debian系列)”呢?因為SUSE這個老六跟別人都不一樣。
幾乎所有的Linux發行版都會存在如下兩個文件:
-rw-r--r-- 1 root root 2259 ?7月 29 ?2021 /etc/pam.d/su
-rw-r--r-- 1 root root ?137 ?7月 29 ?2021 /etc/pam.d/su-l
但是Redhat系列、Debian系列的su-l文件中的內容是這樣的:
#%PAM-1.0
auth ? ? ? ? ? ?include ? ? ? ? su
account ? ? ? ? include ? ? ? ? su
password ? ? ? ?include ? ? ? ? su
session ? ? ? ? optional ? ? ? ?pam_keyinit.so force revoke
session ? ? ? ? include ? ? ? ? su
也就是說su-l引用了su,保證su配置即可。
SUSE嘞~~su-l和su配置是獨立的,并且SUSE10- 版本中沒有su-l這個文件。
~ # diff /etc/pam.d/su /etc/pam.d/su-l
~ # cat /etc/pam.d/su-l
#%PAM-1.0
auth ? ? sufficient ? ? pam_rootok.so
auth ? ? include ? ? ? ?common-auth
account ?sufficient ? ? ? ? pam_rootok.so
account ?include ? ? ? ?common-account
password include ? ? ? ?common-password
session ?include ? ? ? ?common-session
session ?optional ? ? ? pam_xauth.so
su和su-l的區別
直接上結論:/etc/pam.d/su是對su 用戶名進行限制的,而/etc/pam.d/su-l是對 su - 進行限制的。對于-的解釋,執行su --help:
-, -l, --login ? ? ? ? ? ? ? make the shell a login shell
總結
對于SUSE要增加對/etc/pam.d/su-l進行相同配置的檢查。