在 Linux 上搭建 FTP 服务器(常用 vsftpd、ProFTPD、Pure-FTPd)时,日志审计通常用于:
下面以最常见的 vsftpd 为主,兼顾其他服务说明。
编辑配置文件:
vim /etc/vsftpd/vsftpd.conf
关键参数:
# 启用上传/下载日志
xferlog_enable=YES
# 使用标准 xferlog 格式
xferlog_std_format=YES
# 日志文件路径(默认)
xferlog_file=/var/log/xferlog
# 记录详细操作(推荐开启)
log_ftp_protocol=YES
# 双日志(系统日志 + xferlog)
dual_log_enable=YES
vsftpd_log_file=/var/log/vsftpd.log
重启服务:
systemctl restart vsftpd
/var/log/xferlog/var/log/vsftpd.log查看谁下载了文件
grep "DOWNLOAD" /var/log/xferlog
查看登录情况
grep "CONNECT" /var/log/vsftpd.log
某用户操作记录
grep "user1" /var/log/vsftpd.log
vsftpd 默认会把部分日志写入:
/var/log/messages
/var/log/syslog
查看 FTP 登录:
grep vsftpd /var/log/messages
配置文件:
vim /etc/proftpd/proftpd.conf
SystemLog /var/log/proftpd/system.log
TransferLog /var/log/proftpd/transfer.log
ExtendedLog /var/log/proftpd/access.log ALL
启动参数示例:
pure-ftpd -O clf:/var/log/pureftpd.log
或:
pure-ftpd -l puredb:/etc/pure-ftpd/pureftpd.pdb -O clf:/var/log/pureftpd.log
auditctl -w /data/ftp -p rwxa -k ftp_audit
查看审计:
ausearch -k ftp_audit
| 需求 | 推荐方式 |
|---|---|
| 基本审计 | vsftpd + xferlog |
| 详细操作 | log_ftp_protocol=YES |
| 安全合规 | auditd + 日志集中 |
| 企业级 | FTP + SIEM |
如果你愿意,可以告诉我:
我可以给你一份可直接用的配置。