最終更新日:2020年8月8日
オープンソースのウィルス対策ソフトである Clam AntiVirus を CentOS にインストールする
Clam AntiVirus とは
Clam AntiVirus(ClamAV) とは、オープンソースで開発・運用されているウィルス対策ソフトです。商用のウィルス対策ソフトと比べると多少見劣りしてしまいますが、ボランティアによって頻繁にウィルス定義のアップデートが行われており、無償で使用可能なため、広く使用されています。
目次
EPEL リポジトリを追加する
CentOS 6 に Clam AntiVirus をインストールするには、EPEL リポジトリを追加する必要があります。
EPEL リポジトリの追加方法は、以下の記事を参考にしてください。
Clam AntiVirus インストール
以下のコマンドで Clam AntiVirus をインストールします。
# yum --enablerepo=epel -y install clamd
Clam AntiVirus の設定変更
Clam AntiVirus を root 権限で実行するように設定を変更します。
# vi /etc/clamd.conf
User の先頭に#を付けてコメントアウトします。
#User clam
Clam AntiVirus の起動
以下のコマンドで Clam AntiVirus を起動します。また、OS 起動時に Clam AntiVirus が起動するように設定します。
# service clamd start # chkconfig clamd on
起動時に以下のような警告が表示されたら、とりあえず main.cld の方を削除します。
Starting Clam AntiVirus Daemon: LibClamAV Warning: Detected duplicate databases /var/lib/clamav/main.cvd and /var/lib/clamav/main.cld, please manually remove one of them
# rm -f /var/lib/clamav/main.cld
サービスを再起動して警告がでないことを確認します。
# service clamd restart
ウィルス定義のアップデート
以下のコマンドを実行してウィルス定義を最新にします。
# freshclam ClamAV update process started at Sun Nov 10 12:30:17 2013 main.cvd is up to date (version: 55, sigs: 2424225, f-level: 60, builder: neo) daily.cvd is up to date (version: 18090, sigs: 480432, f-level: 63, builder: neo) bytecode.cld is up to date (version: 230, sigs: 43, f-level: 63, builder: dgoddard) [LibClamAV] Detected duplicate databases /var/lib/clamav/daily.cld and /var/lib/clamav/daily.cvd. The /var/lib/clamav/daily.cld database is older and will not be loaded, you should manually remove it from the database directory.
なにやら、また警告が出たので daily.cld を削除して再実行します。
# rm -f /var/lib/clamav/daily.cld # freshclam ClamAV update process started at Sun Nov 10 12:32:28 2013 main.cvd is up to date (version: 55, sigs: 2424225, f-level: 60, builder: neo) daily.cvd is up to date (version: 18090, sigs: 480432, f-level: 63, builder: neo) bytecode.cld is up to date (version: 230, sigs: 43, f-level: 63, builder: dgoddard)
今度は警告が出ないので大丈夫ですね。
以降は、cron の日次タスクで freshclam が実行されるようになります。
ウィルススキャン実行
サンプルのウィルスファイルをダウンロードし、ウィルスをスキャンします。
# wget http://www.eicar.org/download/eicar.com # clamscan --infected --remove --recursive /root/eicar.com: Eicar-Test-Signature FOUND /root/eicar.com: Removed. ----------- SCAN SUMMARY ----------- Known viruses: 2899360 Engine version: 0.98 Scanned directories: 712 Scanned files: 6005 Infected files: 1 Data scanned: 152.24 MB Data read: 122.76 MB (ratio 1.24:1) Time: 22.749 sec (0 m 22 s)
ウィルスを検出して駆除しているのが分かりますね。
スケジュール実行ウィルススキャン設定
シェルスクリプトを作成します。
# vi virusscan
以下の内容を貼り付けします。
#!/bin/bash PATH=/usr/bin:/bin # clamd update yum --enablerepo=epel -y update clamd > /dev/null 2>&1 # virus scan CLAMSCANTMP=`mktemp` clamscan --recursive --remove / > $CLAMSCANTMP 2>&1 [ ! -z "$(grep FOUND$ $CLAMSCANTMP)" ] && \ # when detect virus, send mail grep FOUND$ $CLAMSCANTMP | mail -s "Virus Found in `hostname`" root rm -f $CLAMSCANTMP
実行権限を付与し、日次スケジュールに登録します。
# chmod +x virusscan # mv virusscan /etc/cron.daily/
テストウィルスについて
テストウィルスは以下のサイトより入手可能です。
現在ダウンロードできるのは以下の4種類のファイルです。
http://www.eicar.org/download/eicar.com http://www.eicar.org/download/eicar.com.txt http://www.eicar.org/download/eicar_com.zip http://www.eicar.org/download/eicarcom2.zip
まとめ
昔は Web サーバーにはウィルス対策ソフトをインストールしないということもあったようですが、Web サーバーの改ざんが増えている現在ではリスクを少なくするために、Web サーバーであってもウィルス対策ソフトをインストールした方がよいかと思います。
とはいえ、Web サーバー用のウィルス対策ソフトはそれなりのお値段がします。そうした中で、オープンソースで無償で利用できる Clam AntiVirus は非常に助かる存在です。商用のウィルス対策ソフトには勝てないまでも、最低限のウィルス対策はできる訳ですから。
まだ、Web サーバーにウィルス対策ソフトをインストールしていない場合は、すぐにでも Clam AntiVirus をインストールすることをおすすめします。
最低限必要な CentOS セキュリティ設定
最低限必要な CentOS セキュリティ設定を以下の記事にまとめていますので、こちらもどうぞ。
スポンサーリンク
カテゴリー:ツール
コメントを残す