웹사이트 검색

CentOS 7에서 바이러스 검사를 위해 ClamAV를 PureFTPd에 통합하는 방법


이 튜토리얼은 다음 OS 버전에 대해 존재합니다.

  • 센트OS 7
  • 센트OS 5.4

이 페이지에서

  1. 1 서문
  2. 2 ClamAV 설치
  3. 3 PureFTPd 구성
  4. 4 가상 머신 이미지
    1. SSH 로그인
    2. MariaDB 로그인

    이 튜토리얼에서는 CentOS 7 시스템에서 바이러스 검사를 위해 ClamAV를 PureFTPd에 통합하는 방법을 설명합니다. 결국 PureFTPd를 통해 파일이 업로드될 때마다 ClamAV는 파일을 확인하고 바이러스나 맬웨어가 포함되어 있으면 삭제합니다.

    1 서문

    CentOS 7 서버에서 작동하는 PureFTPd 설정이 있어야 합니다. 이 튜토리얼에서 볼 수 있듯이 CentOS 7에서 PureFTPd 및 MySQL(Incl. Quota and Bandwidth Management)을 사용한 가상 호스팅.

    2 ClamAV 설치

    ClamAV는 공식 CentOS 리포지토리에서 사용할 수 없으므로 EPEL 리포지토리를 활성화합니다(아직 활성화하지 않은 경우) RPM GPK 키를 가져와서 시작합니다.

    rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*

    그런 다음 이 튜토리얼 과정에서 설치할 많은 패키지가 공식 CentOS 7 리포지토리에서 사용할 수 없으므로 CentOS 시스템에서 EPEL 리포지토리를 활성화합니다.

    yum -y install epel-release
    yum -y install yum-priorities

    편집 /etc/yum.repos.d/epel.repo...

    nano /etc/yum.repos.d/epel.repo

    ... 그리고 [epel] 섹션에 priority=10 행을 추가합니다.

    [epel]
    name=Extra Packages for Enterprise Linux 7 - $basearch
    #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
    mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
    failovermethod=priority
    enabled=1
    priority=10
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
    [...]

    그런 다음 시스템에서 기존 패키지를 업데이트합니다.

    yum update

    그런 다음 다음과 같이 ClamAV를 설치할 수 있습니다.

    yum -y clamav clamav-server clamav-data clamav-update clamav-filesystem clamav-scanner-systemd clamav-devel clamav-lib clamav-server-systemd

    /etc/freshclam.conf 파일을 편집하고 Example 줄을 주석 처리합니다.

    nano /etc/freshclam.conf

    Example 행 앞에 #을 추가하여:

    .....
    # Comment or remove the line below.
    # Example

    ....

    그런 다음 /etc/clamd.d/scan.conf 파일을 수정합니다.

    nano /etc/clamd.d/scan.conf

    위의 파일에서 했던 것처럼 Example 줄을 주석 처리하고 LocalSocket 줄 앞의 #을 제거합니다.

    .....
    # Comment or remove the line below.
    # Example

    ....
    LocalSocket /var/run/clamd.scan/clamd.sock
    ....

    다음으로 clamd에 대한 시스템 시작 링크를 만들고 시작합니다.

    systemctl enable 
    freshclam

    그런 다음 clamav 서비스를 시작합니다.

    systemctl start 

    다음 명령으로 ClamAV 데몬의 상태를 확인할 수 있습니다.

     systemctl  status 

    결과는 다음과 같아야 합니다.

    [
    ??10945 /usr/sbin/clamd -c /etc/clamd.d/scan.conf --nofork=yes
    Apr 07 15:44:36 server1.example.com clamd[10945]: HTML support enabled.
    Apr 07 15:44:36 server1.example.com clamd[10945]: XMLDOCS support enabled.
    Apr 07 15:44:36 server1.example.com clamd[10945]: HWP3 support enabled.
    Apr 07 15:44:36 server1.example.com clamd[10945]: Self checking every 600 seconds.
    Apr 07 15:44:36 server1.example.com clamd[10945]: PDF support enabled.
    Apr 07 15:44:36 server1.example.com clamd[10945]: SWF support enabled.
    Apr 07 15:44:36 server1.example.com clamd[10945]: HTML support enabled.
    Apr 07 15:44:36 server1.example.com clamd[10945]: XMLDOCS support enabled.
    Apr 07 15:44:36 server1.example.com clamd[10945]: HWP3 support enabled.
    Apr 07 15:44:36 server1.example.com clamd[10945]: Self checking every 600 seconds.

    3 PureFTPd 구성

    먼저 /etc/pure-ftpd/pure-ftpd.conf를 열고 CallUploadScript를 yes로 설정합니다.

    nano /etc/pure-ftpd/pure-ftpd.conf
    [...]
    # If your pure-ftpd has been compiled with pure-uploadscript support,
    # this will make pure-ftpd write info about new uploads to
    # /var/run/pure-ftpd.upload.pipe so pure-uploadscript can read it and
    # spawn a script to handle the upload.
    # Don't enable this option if you don't actually use pure-uploadscript.
    
    CallUploadScript yes
    [...]

    다음으로 /etc/pure-ftpd/clamav_check.sh 파일을 만듭니다(파일이 PureFTPd를 통해 업로드될 때마다 /usr/bin/clamdscan을 호출함)...

    nano /etc/pure-ftpd/clamav_check.sh
    #!/bin/sh
    /usr/bin/clamdscan --fdpass --remove --quiet --no-summary -c /etc/clamd.d/scan.conf "$1"

    ... 실행 가능하게 만드십시오.

    chmod 755 /etc/pure-ftpd/clamav_check.sh

    이제 pure-uploadscript 프로그램을 데몬으로 시작합니다. 파일이 PureFTPd를 통해 업로드될 때마다 /etc/pure-ftpd/clamav_check.sh 스크립트를 호출합니다.

    pure-uploadscript -B -r /etc/pure-ftpd/clamav_check.sh

    물론 시스템을 부팅할 때마다 데몬을 수동으로 시작하고 싶지는 않으므로 /etc/rc.local...을 엽니다.

    nano /etc/rc.local

    ... 그리고 /usr/sbin/pure-uploadscript -B -r /etc/pure-ftpd/clamav_check.sh 줄을 추가합니다. 다음과 같이:

    #!/bin/sh
    #
    # This script will be executed *after* all the other init scripts.
    # You can put your own initialization stuff in here if you don't
    # want to do the full Sys V style init stuff.
    
    /usr/sbin/pure-uploadscript -B -r /etc/pure-ftpd/clamav_check.sh
    touch /var/lock/subsys/local

    마지막으로 PureFTPd를 다시 시작합니다.

    systemctl restart 

    그게 다야! 이제 누군가 PureFTPd를 통해 서버에 맬웨어를 업로드하려고 할 때마다 "잘못된" 파일이 자동으로 삭제됩니다.

    4 가상 머신 이미지

    이 튜토리얼은 Howtoforge 구독자를 위해 OVA/OVF 형식의 가상 머신을 사용할 준비가 된 상태로 제공됩니다. VM 형식은 VMWare 및 Virtualbox 및 이 형식을 가져올 수 있는 기타 도구와 호환됩니다. 상단 오른쪽 메뉴에서 다운로드 링크를 찾을 수 있습니다. 파일 이름을 클릭하면 다운로드가 시작됩니다.

    VM의 로그인 세부 정보는 다음과 같습니다.

    SSH 로그인

    사용자 이름: root
    비밀번호: howtoforge

    마리아DB 로그인

    사용자 이름: root
    비밀번호: howtoforge

    최초 부팅 후 암호를 변경하십시오.

    5 링크

    • PureFTPD: http://www.pureftpd.org/
    • ClamAV: http://www.clamav.net/
    • CentOS: http://www.centos.org/