1 views
実現する機能
CentOS 6.4インストール直後は、無防備にインターネットに繋がっている状態です。これを解消しつつ、サーバー構築の準備をする、というのがここでの目的です。GNOME端末を使って各種の設定をするので、GNOME端末の使い方がわからない場合は、GNOME端末でviコマンドを使う方法を参照のこと。
※GNOME端末を使って黄色文のとおり入力します。私はコピペ派ですが、コマンドは全く覚えられませんので、覚えたい方は、地道にキーボードを叩いてください。緑は説明文です。赤は注意書き。白はGNOME端末が自動表示している文字や記号です。
手順
(1)アップデートを急ぐのでとりあえずは簡単ネットワーク接続(GUI編)
KPICASA_GALLERY(Network#Gv1sRgCNnG3f-s74a_0QE)
(2)CentOSのアップデート
yum -y update [root@ufuso ~]# yum -y update ← インストール済パッケージの一括アップデート Installed: kernel.x86_64 0:2.6.32-358.2.1.el6 Updated: autofs.x86_64 1:5.0.5-74.el6_4 bind-libs.x86_64 32:9.8.2-0.17.rc1.el6_4.4 bind-utils.x86_64 32:9.8.2-0.17.rc1.el6_4.4 boost-filesystem.x86_64 0:1.41.0-17.el6_4 boost-system.x86_64 0:1.41.0-17.el6_4 coreutils.x86_64 0:8.4-19.el6_4.1 coreutils-libs.x86_64 0:8.4-19.el6_4.1 cups.x86_64 1:1.4.2-50.el6_4.4 cups-libs.x86_64 1:1.4.2-50.el6_4.4 dbus-glib.x86_64 0:0.86-6.el6 firefox.x86_64 0:17.0.5-1.el6.centos freetype.x86_64 0:2.3.11-14.el6_3.1 ghostscript.x86_64 0:8.70-15.el6_4.1 gnome-power-manager.x86_64 0:2.28.3-7.el6_4 gnutls.x86_64 0:2.8.5-10.el6_4.1 initscripts.x86_64 0:9.03.38-1.el6.centos.1 ipa-client.x86_64 0:3.0.0-26.el6_4.2 ipa-python.x86_64 0:3.0.0-26.el6_4.2 java-1.6.0-openjdk.x86_64 1:1.6.0.0-1.57.1.11.9.el6_4 java-1.7.0-openjdk.x86_64 1:1.7.0.9-2.3.8.0.el6_4 kernel-firmware.noarch 0:2.6.32-358.2.1.el6 krb5-libs.x86_64 0:1.10.3-10.el6_4.1 krb5-workstation.x86_64 0:1.10.3-10.el6_4.1 libipa_hbac.x86_64 0:1.9.2-82.4.el6_4 libipa_hbac-python.x86_64 0:1.9.2-82.4.el6_4 libproxy.x86_64 0:0.3.0-4.el6_3 libproxy-bin.x86_64 0:0.3.0-4.el6_3 libproxy-python.x86_64 0:0.3.0-4.el6_3 libsss_autofs.x86_64 0:1.9.2-82.4.el6_4 libsss_idmap.x86_64 0:1.9.2-82.4.el6_4 libxml2.x86_64 0:2.7.6-12.el6_4.1 libxml2-python.x86_64 0:2.7.6-12.el6_4.1 mysql-libs.x86_64 0:5.1.67-1.el6_3 openldap.x86_64 0:2.4.23-32.el6_4 openssl.x86_64 0:1.0.0-27.el6_4.2 perl.x86_64 4:5.10.1-130.el6_4 perl-CGI.x86_64 0:3.51-130.el6_4 perl-ExtUtils-MakeMaker.x86_64 0:6.55-130.el6_4 perl-ExtUtils-ParseXS.x86_64 1:2.2003.0-130.el6_4 perl-Module-Pluggable.x86_64 1:3.90-130.el6_4 perl-Pod-Escapes.x86_64 1:1.04-130.el6_4 perl-Pod-Simple.x86_64 1:3.13-130.el6_4 perl-Test-Harness.x86_64 0:3.17-130.el6_4 perl-Test-Simple.x86_64 0:0.92-130.el6_4 perl-devel.x86_64 4:5.10.1-130.el6_4 perl-libs.x86_64 4:5.10.1-130.el6_4 perl-version.x86_64 3:0.77-130.el6_4 phonon-backend-gstreamer.x86_64 1:4.6.2-26.el6_4 pixman.x86_64 0:0.26.2-5.el6_4 qt.x86_64 1:4.6.2-26.el6_4 qt-sqlite.x86_64 1:4.6.2-26.el6_4 qt-x11.x86_64 1:4.6.2-26.el6_4 selinux-policy.noarch 0:3.7.19-195.el6_4.3 selinux-policy-targeted.noarch 0:3.7.19-195.el6_4.3 spice-vdagent.x86_64 0:0.12.0-4.el6_4.1 sssd.x86_64 0:1.9.2-82.4.el6_4 sssd-client.x86_64 0:1.9.2-82.4.el6_4 tzdata.noarch 0:2013b-1.el6 tzdata-java.noarch 0:2013b-1.el6 xulrunner.x86_64 0:17.0.5-1.el6.centos yelp.x86_64 0:2.28.1-17.el6_3 Complete! |
(3)通常はインターネットプロバイダから支給されたルーターにファイアウォールが設定されているので、サーバーのファイアウォールは停止
[root@ufuso ~]# /etc/rc.d/init.d/iptables stop ← サーバーのファイアウォールを 停止 iptables: ファイアウォールルールを消去中: [ OK ] iptables: チェインをポリシー ACCEPT へ設定中filter [ OK ] iptables: モジュールを取り外し中: [ OK ] [root@ufuso ~]# chkconfig iptables off ← 自動起動の停止 |
(4)動かないソフトが続出するので、原因であるSELinux (Security-Enhanced Linux)を無効にする(初心者でなければセキュリティ強化になる有効を推奨)
[root@ufuso ~]# setenforce 0 ← SELinux無効化 [root@ufuso ~]# getenforce ← SELinux状態確認 Permissive ← SELinux無効 [root@ufuso ~]# vi /etc/sysconfig/selinux ← SELinuxの編集 # 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 |
(5)管理者rootになれるユーザを制限する
[root@ufuso ~]# usermod -G wheel tu ← rootユーザーをtuに限定する [root@ufuso ~]# vi /etc/pam.d/su ← ユーザー認証ファイルの編集 #%PAM-1.0 auth sufficient pam_rootok.so # 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 ← #を削除してrootユーザーに なれる者を限定 auth include system-auth account sufficient pam_succeed_if.so uid = 0 use_uid quiet account include system-auth password include system-auth session include system-auth session optional pam_xauth.so |
(6)日本語処理に必要なnkfコマンドをインストールする
[root@ufuso ~]# yum -y install nkf ← nkfインストール Installed: nkf.x86_64 1:2.0.8b-6.2.el6 Complete! |
(7)RPMforgeリポジトリ導入
[root@ufuso ~]# wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt ← RPMforgeのGPGキー(真正なソフトであることを検証するキー)をダウンロード `RPM-GPG-KEY.dag.txt' に保存中 100%[======================================>] 1,672 --.-K/s 時間 0s 2013-04-17 01:22:50 (35.5 MB/s) - `RPM-GPG-KEY.dag.txt' へ保存完了 [1672/1672] [root@ufuso ~]# rpm --import RPM-GPG-KEY.dag.txt ← RPMforgeのGPGキーをインス トール [root@ufuso ~]# rm -f RPM-GPG-KEY.dag.txt ← RPMforgeのGPGキーを削除 [root@ufuso ~]# vi /etc/yum.repos.d/rpmforge.repo ← rpmforge.repoファイルの 作成 [rpmforge] name=RPMforge RPM repository for Red Hat Enterprise Linux baseurl=http://ftp.riken.jp/Linux/dag/redhat/el6/en/$basearch/rpmforge/ gpgcheck=1 enabled=0 ※「yum install パッケージ名」と入力しても自動でインストールされないので、上記 リポジトリを使用してインストールする場合は、以下のようにコマンドを入力すること yum --enablerepo=rpmforge install パッケージ名 |
(8)EPELリポジトリ導入
[root@ufuso ~]# wget http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6 ← EPELのGPGキー(真正なソフトであることを検証するキー)をダウンロード `RPM-GPG-KEY-EPEL-6' に保存中 100%[======================================>] 1,649 --.-K/s 時間 0s 2013-04-17 01:23:51 (33.5 MB/s) - `RPM-GPG-KEY-EPEL-6' へ保存完了 [1649/1649] [root@ufuso ~]# rpm --import RPM-GPG-KEY-EPEL-6 ← EPELのGPGキーをインストール [root@ufuso ~]# rm -f RPM-GPG-KEY-EPEL-6 ← EPELのGPGキーを削除 [root@ufuso ~]# vi /etc/yum.repos.d/epel.repo ← epel.repoファイルの作成 [epel] name=EPEL RPM Repository for Red Hat Enterprise Linux baseurl=http://ftp.riken.jp/Linux/fedora/epel/6/$basearch/ gpgcheck=1 enabled=0 ※「yum install パッケージ名」と入力しても自動でインストールされないので、上記 リポジトリを使用してインストールする場合は、以下のようにコマンドを入力すること yum --enablerepo=epel install パッケージ名 |
(9)Clam AntiVirusの導入
(A)Clam AntiVirusのインストール
[root@ufuso ~]# yum --enablerepo=rpmforge -y install clamd ← Clam AntiVirus のインストール ・・・ Installed: clamd.x86_64 0:0.97.7-1.el6.rf Dependency Installed: clamav.x86_64 0:0.97.7-1.el6.rf |
(B)Clam AntiVirus設定
[root@ufuso ~]# vi /etc/clamd.conf ← clamd設定ファイル編集 # Run as another user (clamd must be started by root for this option to work) # Default: don't drop privileges #User clamav ← 行頭に#を付加して無効化し、root権限で動作するようにする [root@ufuso ~]# /etc/rc.d/init.d/clamd start ← clamd起動 Starting Clam AntiVirus Daemon: LibClamAV Warning: ************************************************** LibClamAV Warning: *** The virus database is older than 7 days! *** LibClamAV Warning: *** Please update it as soon as possible. *** LibClamAV Warning: ************************************************** [ OK ] [root@ufuso ~]# chkconfig clamd on ← clamd自動起動設定 [root@ufuso ~]# sed -i 's/Example/#Example/g' /etc/freshclam.conf ← ウィルス 定義ファイル更新機能の有効化 [root@ufuso ~]# freshclam ← ウィルス定義ファイル更新 ClamAV update process started at Sat Apr 20 09:03:51 2013 main.cvd is up to date (version: 54, sigs: 1044387, f-level: 60, builder: sven) Downloading daily-17032.cdiff [100%] Downloading daily-17033.cdiff [100%] Downloading daily-17034.cdiff [100%] Downloading daily-17035.cdiff [100%] Downloading daily-17036.cdiff [100%] Downloading daily-17037.cdiff [100%] Downloading daily-17038.cdiff [100%] Downloading daily-17039.cdiff [100%] Downloading daily-17040.cdiff [100%] Downloading daily-17041.cdiff [100%] Downloading daily-17042.cdiff [100%] Downloading daily-17043.cdiff [100%] Downloading daily-17044.cdiff [100%] Downloading daily-17045.cdiff [100%] daily.cld updated (version: 17045, sigs: 1124675, f-level: 63, builder: neo) bytecode.cvd is up to date (version: 214, sigs: 41, f-level: 63, builder: neo) Database updated (2169103 signatures) from db.jp.clamav.net (IP: 219.94.128.99) ← 更新完了 |
(C)ウィルススキャンテスト
[root@ufuso ~]# clamscan --infected --remove --recursive / ← ウィルススキャン テスト。14分以上かかった ----------- SCAN SUMMARY ----------- Known viruses: 2153328 Engine version: 0.97.7 Scanned directories: 15684 Scanned files: 94244 Infected files: 0 ← ウィルスは検知されなかった Total errors: 7083 Data scanned: 3315.48 MB Data read: 3715.40 MB (ratio 0.89:1) Time: 861.889 sec (14 m 21 s) |
(D)ウィルススキャン定期自動実行設定
[root@ufuso ~]# vi virusscan ← ウィルススキャン実行スクリプト作成 #!/bin/bash PATH=/usr/bin:/bin # clamd update yum -y --enablerepo=rpmforge update clamd > /dev/null 2>&1 # excludeopt setup excludelist=/root/clamscan.exclude if [ -s $excludelist ]; then for i in `cat $excludelist` do if [ $(echo "$i"|grep \/$) ]; then i=`echo $i|sed -e 's/^\([^ ]*\)\/$/\1/p' -e d` excludeopt="${excludeopt} --exclude-dir=^$i" else excludeopt="${excludeopt} --exclude=^$i" fi done fi # virus scan CLAMSCANTMP=`mktemp` clamscan --recursive --remove ${excludeopt} / > $CLAMSCANTMP 2>&1 [ ! -z "$(grep FOUND$ $CLAMSCANTMP)" ] && \ # report mail send grep FOUND$ $CLAMSCANTMP | mail -s "Virus Found in `hostname`" root rm -f $CLAMSCANTMP [root@ufuso ~]# chmod +x virusscan ← 実行スクリプトに実行権限付加 [root@ufuso ~]# echo "/mnt/" >> clamscan.exclude ← スキャン対象外フォルダの 設定例)。ディレクトリを除外する場合は末尾に「/」を付加すること [root@ufuso ~]# ./virusscan ← スクリプトの試行。時間がかかる [root@ufuso ~]# mv virusscan /etc/cron.daily/ ← 実行スクリプトを毎日自動実行 するディレクトリへ移動 |
コメントを残す