监控 Ubuntu 上的 FTPServer(通常是 vsftpd) 可以从 服务状态、连接情况、日志、性能、安全 几个层面来做。下面给你一套实用且可落地的监控方案,从简单到进阶。
最常见的是 vsftpd:
dpkg -l | grep vsftpd
或者:
ps aux | grep ftp
systemctl status vsftpd
✅ 正常运行应显示 active (running)
sudo systemctl enable vsftpd
netstat -anp | grep :21
或(新系统):
ss -tnp | grep :21
ftpwho
(部分系统需要安装)
sudo apt install ftpwho
ss -tn | grep :21 | wc -l
/var/log/vsftpd.log
查看实时日志:
tail -f /var/log/vsftpd.log
示例:
grep "FAIL" /var/log/vsftpd.log
sudo apt install fail2ban
编辑配置:
sudo nano /etc/fail2ban/jail.local
示例:
[vsftpd]
enabled = true
port = ftp,ftp-data,ftps,ftps-data
filter = vsftpd
logpath = /var/log/vsftpd.log
maxretry = 5
bantime = 3600
重启:
sudo systemctl restart fail2ban
查看封禁 IP:
fail2ban-client status vsftpd
top
htop
iotop
iftop
| 项目 | 方法 |
|---|---|
| FTP 是否存活 | net.tcp.listen[21] |
| 当前连接数 | ss -tn | grep :21 | wc -l |
| 登录失败 | log count |
如果是 FTPS(FTP over SSL):
openssl x509 -in /etc/ssl/certs/vsftpd.pem -noout -dates
✅ 服务器必做
systemctl status vsftpd
tail -f /var/log/vsftpd.log
fail2ban
✅ 安全必做
如果你愿意,我可以:
你现在用的是 FTP 还是 FTPS?有没有公网暴露?