rootのパスワードが分かってしまったら、
どんなユーザでもrootになれてしまいます。
そこで、ちょこちょこして制限をかけてしまいます。
・/etc/login.defsの編集
・/etc/pam.d/suの編集
・許可ユーザをwheelグループに追加
(CentOSでもScientific Linuxでも同じです)
1)/etc/login.defsの編集
追記
# vi /etc/login.defs SU_WHEEL_ONLY yes ← 追記
これだけ
2)/etc/pam.d/suの編集
アンコメント
# vi /etc/pam.d/su # 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. auth required pam_wheel.so use_uid ← こっち
3)su 許可ユーザをwheelグループに追加
とりあえずユーザを作ってみましょ
# adduser hoge # usermod -G wheel hoge # id hoge uid=xxx(hoge) gid=xxx(hoge) 所属グループ=xxx(hoge),10(wheel) # adduser geho # id geho uid=xxx(geho) gid=xxx(geho) 所属グループ=xxx(geho)
su出来る人
[hoge@srv ~]$ su パスワード: rootのパスワード [root@srv ~]#
su出来ない人
[geho@srv ~]$ su パスワード: rootのパスワード su: パスワードが違います
パスワード無しで「su」なりたい場合
上のほうをアンコメントします
# 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. #auth required pam_wheel.so use_uid
こちらは、アンコメントしておきます。
# vi /etc/login.defs # SU_WHEEL_ONLY yes
これで、suしたときにパスワードは聞かれません。
が、流石にセキュリティ的にどうかと思うのでオススメしませんw
[tegaki]す ってやっちゃうw[/tegaki]