监控 Linux 上的 FTP 服务器(如 vsftpd、ProFTPD、Pure-FTPd 等)可以从服务状态、连接情况、日志、性能、安全几个层面来做。下面按常见场景给你一个实用方案。
先确认你用的是哪种 FTP 服务:
ps aux | grep -E "vsftpd|proftpd|pure-ftpd"
或者:
systemctl list-units | grep ftp
systemctl status vsftpd
设置开机自启并监控:
systemctl enable vsftpd
pgrep vsftpd
netstat -antp | grep :21
# 或
ss -antp | grep :21
ss -ant | grep :21 | wc -l
watch -n 1 "ps -ef | grep ftp"
/var/log/vsftpd.log
/var/log/messages
实时查看:
tail -f /var/log/vsftpd.log
常见关注点:
示例:
grep "FAIL" /var/log/vsftpd.log
apt install fail2ban
配置:
[vsftpd]
enabled = true
port = ftp
logpath = /var/log/vsftpd.log
maxretry = 5
net.tcp.listen[21]
max_clients=50
max_per_ip=5
#!/bin/bash
if ! systemctl is-active --quiet vsftpd; then
echo "vsftpd is down!" | mail -s "FTP Alert" admin@xxx.com
fi
如果你能告诉我:
我可以给你更精确的配置示例。