Wednesday, May 28, 2014

Install ClamAV and Configure Daily Scanning on CentOS

ClamAV is an open source (GPL) antivirus engine designed for detecting Trojans, viruses, malware and other malicious threats on Linux. 

In this article, we will only be configuring ClamAV to run scheduled/on-demand scans; not resident scans.

1. Install EPEL repo

Before we can do proceed, you must ensure that you have the EPEL yum repository enabled.
CentOS 6 – 32-bit
CentOS 6 – 64-bit
CentOS 5 – 32-bit
 CentOS 5 – 64-bit
After running the above commands for your relevant CentOS version, the following file is created:
/etc/yum.repos.d/epel.repo
The above file can be edited directly to enable or disable the EPEL repo.

 2. Install required ClamAV packages

1yum install clamav clamd

3. Start the clamd service and set it to auto-start

1/etc/init.d/clamd on
2chkconfig clamd on
3/etc/init.d/clamd start

4. Update ClamAV’s signatures

1/usr/bin/freshclam
Note: ClamAV will update automatically, as part of /etc/cron.daily/freshclam.

B. Configure Daily Scan

In this example, we will configure a cronjob to scan the /home/ directory every day:

1. Create cron file:

1vim /etc/cron.daily/manual_clamscan
Add the following to the file above. Be sure to change SCAN_DIR to the directory that you want to scan:
1#!/bin/bash
2SCAN_DIR="/home"
3LOG_FILE="/var/log/clamav/manual_clamscan.log"
4/usr/bin/clamscan -i -r $SCAN_DIR >> $LOG_FILE
Give our cron script executable permissions:
1chmod +x /etc/cron.daily/manual_clamscan
You can even run the above script to ensure that it works correctly.

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews