okochangの馬鹿でありがとう

ふらふら適当に世間を生きる日々でございます

CentOS公式AMIの起動とServerProtectのインストール

先日JAWS-UG東京に参加しながらTwitterでこんな会話をしていました。



Trend Micro社のServerProtectはカーネルが対応していればリアルタイム検索も出来るみたいだったので、ちょっと自分でも調べてみようかなーと思って試してみる事にしました。

使用したAMI

最近CentOSの公式AMIがAWS MarketPlaceで配布されるようになったので、今回はこちらを使ってみたいと思います。

  • ami-6644fa67

インスタンスはm1.smallで起動し、エフェメラルストレージを/dev/sdbにアタッチしました。

基本設定

CetnOSが公式で配布しているAMIから起動した場合の初回ログインはrootユーザーになります。

$ ssh -i .ssh/your_key.pem root@55.44.33.22

もし起動時にルートボリュームのEBSを拡張した場合は以下のようにOS側からも認識させます。

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvde             7.9G  625M  6.9G   9% /
tmpfs                 828M     0  828M   0% /dev/shm
# resize2fs /dev/sda 
# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvde             9.9G  625M  8.8G   7% /
tmpfs                 828M     0  828M   0% /dev/shm

タイムゾーンを日本時間に変更します。

# date
2013年  2月 11日 月曜日 11:38:56 UTC
# cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
# date
2013年  2月 11日 月曜日 20:39:02 JST

スワップ領域としてエフェメラルストレージを使用するように設定します。
OS側からは/dev/xvdfとして認識されてました。

# free
             total       used       free     shared    buffers     cached
Mem:       1695376     124424    1570952          0       4668      34056
-/+ buffers/cache:      85700    1609676
Swap:            0          0          0
# mkswap /dev/xvdf 
# swapon /dev/xvdf 
# free
             total       used       free     shared    buffers     cached
Mem:       1695376     240744    1454632          0       5468      34536
-/+ buffers/cache:     200740    1494636
Swap:    156352504          0  156352504
# vi /etc/fstab
/dev/xvde               /        ext4      defaults         0 0
devpts     /dev/pts  devpts  gid=5,mode=620   0 0
tmpfs      /dev/shm  tmpfs   defaults         0 0
proc       /proc     proc    defaults         0 0
sysfs      /sys      sysfs   defaults         0 0
/dev/xvdf  swap      swap    defaults         0 0

パッケージを最新のものにアップデートします。

# yum update

CentOSの公式AMIはデフォルトでiptablesが有効になっています。

# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         

CentOSの公式AMIはデフォルトでSELinuxが有効になっています。

# getenforce 
Enforcing

SELinuxを無効にする場合は以下の手順で出来るようですが、その場合は『とある方に謝る』のがインフラエンジニアの定石であるとTwitterで知りました。(違
※きちんとポリシーに従って判断して下さい。

# vi /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

# reboot
# getenforce 
Disabled

CentOS公式のAMIはデフォルトでSSHのパスワード認証が有効になっています。
公開鍵認証のみを使用する場合は必要がないので無効にしておきます。

# cp -R /etc/ssh/sshd_config /etc/ssh/sshd_config-orig
# vi /etc/ssh/sshd_config
# diff -u /etc/ssh/sshd_config-orig /etc/ssh/sshd_config
--- /etc/ssh/sshd_config-orig	2013-02-11 12:04:38.633585149 +0000
+++ /etc/ssh/sshd_config	2013-02-11 12:05:08.141592560 +0000
@@ -63,7 +63,7 @@
 # To disable tunneled clear text passwords, change to no here!
 #PasswordAuthentication yes
 #PermitEmptyPasswords no
-PasswordAuthentication yes
+PasswordAuthentication no
 
 # Change to no to disable s/key passwords
 #ChallengeResponseAuthentication yes
# service sshd restart

ServerProtectのインストール

ServerProtectのインストールに必要なパッケージをインストールします。

# yum install compat-libstdc++-33 gtk2 pango atk gcc make glibc ld-linux.so.2 libstdc++-libc6.2-2.so.3 libz.so.1 libuuid.so.1 perl

トレンドマイクロのサイトからServerProtectをダウンロードします。

# curl -LO http://www.trendmicro.com/ftp/products/splx/SPLX30_CentOS6.tgz

MD5チェックサムを確認します。

# md5sum SPLX30_CentOS6.tgz 
1587a9d58ab3d7b3af6e4c87bd7618d3  SPLX30_CentOS6.tgz

ダウンロードしたファイルを解凍します。

# tar zxf ./SPLX30_CentOS6.tgz 

インストーラーを実行します。
途中でエンドユーザー使用許諾契約書が表示されるので、同意しましょう。

# ./SProtectLinux-3.0.bin -n

インストール途中で以下のようにアクティベーションコードの入力が求められますが、今回はCtrl+Dを実行して進みます。

Step 2. Activate
Type the Activation Code received after registration to activate ServerProtect.
(Press [Ctrl+D] to abort activation.)

Activation Code: 

さらにインストーラを進めると、ウイルストラッキングプログラムへ参加するか回答を求められます。
これは後ほどWebコンソールから変更が可能なようでしたので一旦yesで進めます。

World Virus Tracking Program

--中略--

Please input your choice [Yes] : Yes

最後に以下のように表示されたらインストールが完了みたいです。
※自動起動を有効にして下さいというメッセージ出力されているので、必要に応じて設定して下さい。

Warning!!!
ServerProtect services will not be added into system initial services!
Please use "/sbin/chkconfig --level 345 splx on" to add splx into system initial services.
Instead of commands, you can execute "/opt/TrendMicro/SProtectLinux/SPLX.util/add_splx_service".

ServerProtect for Linux installation completed.

マニュアルに記載されているKernelのバージョンであれば、リアルタイム検索に必要なカーネルフックモジュールが自動的にインストールされるようです。
今回使用したCentOS6では対応していないため、カーネルフックモジュールを別途インストールする必要があるって事ですかね。
リアルタイム検索が必要ないのであれば、tmsplx.xml設定ファイルのRealtimeScanパラメータを0にするみたいですが、次回にでもカーネルフックもジュールを構築してみようかな。