Akio's Log

ソフトウェア開発、プロジェクトマネジメント、プログラミング、ランニングなどなど

自分サーバの構築その7:各種初期設定

yum update

インストール済みの各パッケージ等を最新にする

[root@xxxxxx]# yum update

ユーザの作成

root以外のユーザが存在しないため、一般ユーザのアカウントを作成する。

[root@xxxxxx]# useradd hanzawa --> hanzawaユーザ追加
[root@xxxxxx]# passwd hanzawa --> hanzawaユーザのパスワード変更
Changing password for user hanzawa.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

[root@xxxxxxx]# su - hanzawa ---> suしてみる
[hanzawa@xxxxxx]$ pwd
/home/hanzawa
ちゃんとホームディレクトリが作成されました

rootになれるユーザを制限

通常は誰でも(どのユーザでも)rootにsuする事が出来るが、よりセキュアにするために、rootになれるユーザを制限する事が出来る。

[root@xxxxxx]# usermod -G wheel hanzawa ---> ユーザhanzawaをグループwheelに追加
[root@xxxxxx]# groups hanzawa ---> hanzawaユーザの所属グループを確認
hanzawa : hanzawa wheel

[root@xxxxxx]# vi /etc/pam.d/su
(略)
#auth required pam_wheel.so use_uid
~
↓ コメント解除
auth required pam_wheel.so use_uid

[root@xxxxxx]# vi /etc/login.defs
(最終行に追加)
SU_WHEEL_ONLY yes

先ほどwheelグループに追加したhanzawa以外のユーザを作成して、そのユーザからsuしてみる。

[hogehoge@xxxxxx] $ su -
パスワード:
su: パスワードが違います

rootユーザにsu出来ない事が確認できた。