ClamAV設定(AlmaLinux)

【PR】
※IT系の記事は当方環境での実施内容となるため実施する場合は自己責任でお願いいたします。

環境

more /etc/redhat-release
AlmaLinux release 8.6 (Sky Tiger)

こちらを参考にさせていただきました。

Clam AntiVirus(アンチウィルスソフト)の設定方法 (mydns.jp)

インストール

dnf install epel-release
dnf install clamav clamav-data clamav-devel clamav-filesystem clamav-update clamd

ウィルス退避用ディレクトリ作成

mkdir /tmp/virus

/etc/clamd.d/scan.confの編集

vi /etc/clamd.d/scan.conf
#Example ← 行頭に#を追加してコメントアウト(初めから#になっていれば何もしない)

#User clamscan ← 行頭に#を追加
↓
User root ← 追加

LogFile /var/log/clamd.scan ← 行頭の#を削除
LogFileMaxSize 2M ← 行頭の#を削除
LogTime yes ← 行頭の#を削除
LogRotate yes ← 行頭の#を削除
LocalSocket /run/clamd.scan/clamd.sock ← 行頭の#を削除
FixStaleSocket yes ← 行頭の#を削除
ExcludePath ^/proc/ ← 行頭の#を削除
ExcludePath ^/sys/ ← 行頭の#を削除
ExcludePath ^/sys/ ← 行頭の#を削除
ExcludePath ^/tmp/virus/ ← 追加

/etc/freshclam.confの編集

vi /etc/freshclam.conf
# Examplee ← 行頭に#を追加してコメントアウト(ウイルス定義ファイル更新機能の有効化 初めから#になっていれば何もしない)

UpdateLogFile /var/log/freshclam.log ← 行頭の#を削除
LogFileMaxSize 2M ← 行頭の#を削除
LogTime yes ← 行頭の#を削除
LogRotate yes ← 行頭の#を削除

DatabaseOwner root ← 変更
DatabaseMirror db.jp.clamav.net ← 変更(変更しなくても多分問題はない)
NotifyClamd /etc/clamd.d/scan.conf ← 変更

ウィルス定義最新化

freshclam

起動

systemctl enable clamd@scan
systemctl start clamd@scan
systemctl status clamd@scan

テスト

万一のために–removeは付けないで結果だけ確認

clamdscanと違い、clamscanは都度スキャン用のようなもので遅いし、リソースも食うようです。

メモリ2Gサーバで「/」に実行したら途中で「Kill」されました・・・やっぱ4Gぐらいないとだめかなぁ。

clamscan --infected --recursive /home

freshclamの起動

systemctl enable clamav-freshclam
systemctl start clamav-freshclam
systemctl status clamav-freshclam

設定確認

clamconf -n
Checking configuration files in /etc

Config file: clamd.d/scan.conf
------------------------------
LogFile = "/var/log/clamd.scan"
LogFileMaxSize = "2097152"
LogTime = "yes"
LogSyslog = "yes"
LogRotate = "yes"
LocalSocket = "/run/clamd.scan/clamd.sock"
ExcludePath = "^/proc/", "^/sys/", "^/tmp/virus/"
User = "root"

Config file: freshclam.conf
---------------------------
LogFileMaxSize = "2097152"
LogTime = "yes"
LogRotate = "yes"
UpdateLogFile = "/var/log/freshclam.log"
DatabaseOwner = "root"
DatabaseMirror = "database.clamav.net"

・
・
・

rootのCronにスケジュール追加

0 5 * * * clamdscan -c /etc/clamd.d/scan.conf --move=/tmp/virus /

とか。

ただ、clamd@scanがメモリを1Gぐらい食ってしまうのが・・・

clamav-freshclamの実行間隔

ちなみにfreshclamってデフォルト2時間おきに更新ということだけど手動で実行したらログに吐かれるけどそれ以外は一向に記録されないなと思っていたのですが、ちゃんと動いているようですな。

systemctl status clamav-freshclam
● clamav-freshclam.service - ClamAV virus database updater
   Loaded: loaded (/usr/lib/systemd/system/clamav-freshclam.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2022-07-08 14:44:32 JST; 10h ago
     Docs: man:freshclam(1)
           man:freshclam.conf(5)
           https://docs.clamav.net/
 Main PID: 1047991 (freshclam)
    Tasks: 1 (limit: 104857)
   Memory: 2.1M
   CGroup: /system.slice/clamav-freshclam.service
           mq1047991 /usr/bin/freshclam -d --foreground=true

Jul 08 22:44:33 xxxxxx freshclam[1047991]: Received signal: wake up
Jul 08 22:44:33 xxxxxx freshclam[1047991]: ClamAV update process started at Fri Jul  8 22:44:33 2022
Jul 08 22:44:33 xxxxxx freshclam[1047991]: daily.cld database is up-to-date (version: 26596, sigs: 1989075, f-level: 90, builder: raynman)
Jul 08 22:44:33 xxxxxx freshclam[1047991]: main.cvd database is up-to-date (version: 62, sigs: 6647427, f-level: 90, builder: sigmgr)
Jul 08 22:44:33 xxxxxx freshclam[1047991]: bytecode.cvd database is up-to-date (version: 333, sigs: 92, f-level: 63, builder: awillia2)
Jul 09 00:44:33 xxxxxx freshclam[1047991]: Received signal: wake up
Jul 09 00:44:33 xxxxxx freshclam[1047991]: ClamAV update process started at Sat Jul  9 00:44:33 2022
Jul 09 00:44:34 xxxxxx freshclam[1047991]: daily.cld database is up-to-date (version: 26596, sigs: 1989075, f-level: 90, builder: raynman)
Jul 09 00:44:34 xxxxxx freshclam[1047991]: main.cvd database is up-to-date (version: 62, sigs: 6647427, f-level: 90, builder: sigmgr)
Jul 09 00:44:34 xxxxxx freshclam[1047991]: bytecode.cvd database is up-to-date (version: 333, sigs: 92, f-level: 63, builder: awillia2)

 

 

Setup_Memo

Posted by admin