温馨提示×

怎么监控debian ftpserver

小樊
53
2026-10-18 12:05:07
栏目: 智能运维

在 Debian 上监控 FTP 服务器,通常取决于你使用的 FTP 服务软件(最常见的是 vsftpd、ProFTPD 或 Pure-FTPd)。下面以 vsftpd(Debian 默认常见选择) 为主,兼顾通用方案,给你一套实用监控思路。


一、确认 FTP 服务状态

1. 查看服务是否运行

systemctl status vsftpd

或

service vsftpd status

2. 开机自启检查

systemctl is-enabled vsftpd

二、实时监控连接情况

1. 查看当前 FTP 连接

netstat -antp | grep :21

或(推荐)

ss -tnp | grep :21

2. 查看登录用户

who

(仅对部分 FTP 服务有效)


三、日志监控(最重要)

vsftpd 日志位置

/var/log/vsftpd.log

(如未生成,需在配置中开启)

开启详细日志(/etc/vsftpd.conf)

xferlog_enable=YES
log_ftp_protocol=YES

重启服务:

systemctl restart vsftpd

实时查看日志

tail -f /var/log/vsftpd.log

监控异常登录

grep "FAIL" /var/log/vsftpd.log

四、系统级监控工具

1. 使用 fail2ban(防暴力破解)

apt install fail2ban

配置:

/etc/fail2ban/jail.local

示例:

[vsftpd]
enabled = true
port = ftp
logpath = /var/log/vsftpd.log
maxretry = 5

2. 使用 monit

apt install monit

示例监控 vsftpd:

check process vsftpd with pidfile /run/vsftpd.pid
    start program = "/usr/sbin/service vsftpd start"
    stop program  = "/usr/sbin/service vsftpd stop"
    if failed port 21 protocol ftp then restart

五、图形化 / 远程监控(可选)

  • Zabbix / Prometheus + Node Exporter
  • Netdata(轻量实时)
bash <(curl -Ss https://my-netdata.io/kickstart.sh)

六、安全建议

  • 禁用匿名登录
  • 使用 SFTP(SSH)替代 FTP(更安全)
  • 限制 IP 访问(firewalld / iptables)

如果你能告诉我:

  • 使用的是 vsftpd / proftpd / pure-ftpd
  • 是想 防攻击 / 看流量 / 看连接数 / 自动化告警

我可以给你更精准的监控方案。

0 踩