2013年6月12日水曜日

CentOSの設定1(Serversman@VPS)

VPSを借りたので、セキュリティ的に設定しなければならない事を忘れないようにメモします。
ちなみに契約したのは一番安いEntryプランです。
OSは「CentOS6.3」で不要なソフトが入ってない「シンプルセット」にしました。



Serversman@VPSではroot権限を発行してくれるので、
まずroot権限でssh接続します。
(接続元PC)$ ssh -p 3843 root@xxx.xxx.xxx.xxx ← 接続先のIPアドレス

Serversman@VPSではsshの接続ポートが22から3843に変わっているので注意。

 

root権限とはシステムに対し、どのような操作も出来てしまう権限で、そのままでは危険なので一般ユーザーを追加して、rootではログイン出来ないように設定をします。
# useradd -m -G wheel -s /bin/bash xxxxx ← ユーザー名
# passwd xxxxx ←上で作ったユーザー名
Changing password for user xxxxx.
New UNIX password: 設定するパスワードを入力
Retype new UNIX password: 同じパスワードをもう一度入力
passwd: all authentication tokens updated successfully.

 

続いてrootユーザーのパスワードを変更します。
# passwd
Changing password for user root.
New UNIX password: 設定するパスワードを入力
Retype new UNIX password: 同じパスワードをもう一度入力
passwd: all authentication tokens updated successfully.

 

wheelグループのユーザーのみがrootになれるように設定する。
# vim /etc/pam.d/su

#auth    required    pam_wheel.so use_uid
   ↓ コメントを外す
auth requied pam wheel.so use_uid

 

sshの接続にrootユーザーが出来ないように設定します。
# vim /etc/ssh/sshd_config

#PermitRootLogin yes
   ↓
#PermitRootLogin yes
PermitRootLogin no

 

設定したらsshdを再起動します。
# service sshd restart

これでsshでrootユーザーではログイン出来なくなりました。

今日は疲れたのでここまで。

0 件のコメント:

コメントを投稿