Scientific Linux 6.4 インストール直後の初期設定
1 views
実現する機能
Scientific Linux 6.4インストール直後は、無防備にインターネットに繋がっている状態です。これを解消しつつ、サーバー構築の準備をする、というのがここでの目的です。GNOME端末を使って各種の設定をするので、GNOME端末の使い方がわからない場合は、GNOME端末でviコマンドを使う方法を参照のこと。SELinuxは有効の状態で運用します。
※GNOME端末を使って黄色文のとおり入力します。私はコピペ派ですが、コマンドは全く覚えられませんので、覚えたい方は、地道にキーボードを叩いてください。緑は説明文です。赤は注意書き。白はGNOME端末が自動表示している文字や記号です。
手順
(1)アップデートに時間がかからないよう通信速度の早いミラーサーバーに繋げる設定
yum -y update [root@ufuso ~]# vi /etc/yum.repos.d/sl.repo ← sl.repoの編集 [sl] name=Scientific Linux $releasever - $basearch baseurl=http://ftp.scientificlinux.org/linux/scientific/$releasever/$basearch/os/ http://ftp1.scientificlinux.org/linux/scientific/$releasever/$basearch/os/ http://ftp2.scientificlinux.org/linux/scientific/$releasever/$basearch/os/ ftp://ftp.scientificlinux.org/linux/scientific/$releasever/$basearch/os/ mirrorlist=http://ftp.scientificlinux.org/linux/scientific/mirrorlist/sl-base-6.txt ← 行頭の#を削除してミラーサーバーを使えるようにする enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-sl file:///etc/pki/rpm-gpg/RPM-GPG-KEY-sl6 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-cern [root@ufuso ~]# vi /etc/yum.repos.d/sl-other.repo ← sl-other.repoの編集 [sl-fastbugs] name=Scientific Linux $releasever - $basearch - fastbug updates baseurl=http://ftp.scientificlinux.org/linux/scientific/$releasever/$basearch/updates/fastbugs/ http://ftp1.scientificlinux.org/linux/scientific/$releasever/$basearch/updates/fastbugs/ http://ftp2.scientificlinux.org/linux/scientific/$releasever/$basearch/updates/fastbugs/ ftp://ftp.scientificlinux.org/linux/scientific/$releasever/$basearch/updates/fastbugs/ mirrorlist=http://ftp.scientificlinux.org/linux/scientific/mirrorlist/sl-fastbugs-6.txt ← 行頭の#を削除してミラーサーバーを使えるようにする enabled=0 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-sl file:///etc/pki/rpm-gpg/RPM-GPG-KEY-sl6 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-cern [root@ufuso ~]# yum -y install yum-plugin-fastestmirror ← 早いミラーサーバーを探すツールのインストール Installed: yum-plugin-fastestmirror.noarch 0:1.1.30-14.el6 Complete! |
(2)Scientific Linuxのアップデート
yum -y update [root@ufuso ~]# yum -y update ← インストール済パッケージの一括アップデート Installed: kernel.x86_64 0:2.6.32-358.6.2.el6 Updated: 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 cups.x86_64 1:1.4.2-50.el6_4.4 cups-libs.x86_64 1:1.4.2-50.el6_4.4 curl.x86_64 0:7.19.7-36.el6_4 dbus-glib.x86_64 0:0.86-6.el6_4 firefox.x86_64 0:17.0.6-1.el6_4 gnutls.x86_64 0:2.8.5-10.el6_4.1 kernel-firmware.noarch 0:2.6.32-358.6.2.el6 krb5-libs.x86_64 0:1.10.3-10.el6_4.2 krb5-workstation.x86_64 0:1.10.3-10.el6_4.2 libcurl.x86_64 0:7.19.7-36.el6_4 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 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.69-1.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 sl-release-notes.noarch 0:6.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 xulrunner.x86_64 0:17.0.6-2.el6_4 Complete! |
(3)通常はインターネットプロバイダから支給されたルーターにファイアウォールが設定されているので、サーバーのファイアウォールは停止
[root@ufuso ~]# /etc/rc.d/init.d/iptables stop ← サーバーのファイアウォールを 停止 iptables: ファイアウォールルールを消去中: [ OK ] iptables: チェインをポリシー ACCEPT へ設定中filter [ OK ] iptables: モジュールを取り外し中: [ OK ] [root@ufuso ~]# chkconfig iptables off ← 自動起動の停止 [root@ufuso ~]# chkconfig ip6tables off ← ip6も自動起動の停止 |
(4)管理者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 |
(5)日本語処理に必要なnkfコマンドをインストールする
[root@ufuso ~]# yum -y install nkf ← nkfインストール Installed: nkf.x86_64 1:2.0.8b-6.2.el6 Complete! |
(6)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-05-18 20:53:39 (38.4 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 パッケージ名 |
(7)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-05-18 20:54:28 (19.6 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 パッケージ名 |
(8)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 clamav-db.x86_64 0:0.97.7-1.el6.rf Complete! |
(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-17240.cdiff [100%] Downloading daily-17241.cdiff [100%] Downloading daily-17242.cdiff [100%] Downloading daily-17243.cdiff [100%] daily.cld updated (version: 17243, sigs: 1278091, f-level: 63, builder: neo) bytecode.cvd is up to date (version: 214, sigs: 41, f-level: 63, builder: neo) Database updated (2322519 signatures) from db.jp.clamav.net (IP: 120.29.176.126) Clamd successfully notified about the update. ← 更新完了 |
(C)ウィルススキャン定期自動実行設定
[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/ ← 実行スクリプトを毎日自動実行 するディレクトリへ移動 |