本教程将介绍如何将ClamAV集成到PureFTPd中,以便在Fedora 18系统上进行病毒扫描。 最后,每当通过PureFTPd上传文件时,ClamAV将检查文件并将其删除,如果它是恶意软件。
1初步说明
您应该在Fedora 18服务器上安装一个工作的PureFTPd设置,例如本教程所示: 使用PureFTPd和MySQL进行虚拟托管(包括配额和带宽管理)在Fedora 18上 。
2安装ClamAV
ClamAV可以安装如下:
yum install amavisd-new clamav clamav-data clamav-server clamav-update clamav-scanner
接下来,我们为clamd创建系统启动链接并启动它:
systemctl enable clamd.amavisd.service
systemctl start clamd.amavisd.service
3配置PureFTPd
首先我们打开/etc/pure-ftpd/pure-ftpd.conf
并将CallUploadScript
设置为yes
:
vi /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. CallUploadScript yes [...] |
接下来,我们创建文件/etc/pure-ftpd/clamav_check.sh
(每当通过PureFTPd上传文件时,它将调用/ usr / bin /
clamdscan)...
vi /etc/pure-ftpd/clamav_check.sh
#!/bin/sh /usr/bin/clamdscan --remove --quiet --no-summary "$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
...
vi /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 |
如果/etc.rc.local
不存在,创建它( 开头
使用#!/ bin / sh
行),然后使其可执行:
chmod 755 /etc/rc.local
最后我们重新启动PureFTPd:
systemctl restart pure-ftpd.service
而已! 现在每当有人尝试通过PureFTPd将恶意软件上传到您的服务器时,“坏”文件将被默认删除。
4链接
- PureFTPD: http : //www.pureftpd.org/
- ClamAV: http : //www.clamav.net/
- Fedora: http : //fedoraproject.org/