温馨提示×

如何监控debian ftpserver

小樊
44
2026-09-03 17:28:14
栏目: 智能运维

在 Debian 上监控 FTP 服务器,通常取决于你使用的是哪种 FTP 服务(如 vsftpd、ProFTPD、Pure-FTPd)。下面以最常见的 vsftpd 为例,系统性地说明监控方法,并补充通用方案。


一、确认 FTP 服务状态

1. 查看服务是否运行

systemctl status vsftpd

service vsftpd status

2. 设置开机自启并监控

systemctl enable vsftpd
systemctl start vsftpd

二、实时监控连接情况

1. 查看当前 FTP 连接

netstat -antp | grep :21

或(推荐)

ss -antp | grep :21

2. 查看登录用户

who

(仅对部分 FTP 服务有效)

3. vsftpd 日志

tail -f /var/log/vsftpd.log

若无该文件,查看:

tail -f /var/log/syslog | grep vsftpd

三、登录与传输审计

vsftpd 配置日志

编辑配置文件:

/etc/vsftpd.conf

确保包含:

xferlog_enable=YES
xferlog_file=/var/log/vsftpd.log
log_ftp_protocol=YES

重启服务:

systemctl restart vsftpd

查看上传/下载记录:

cat /var/log/vsftpd.log

四、资源与性能监控

1. CPU / 内存

top
htop

2. 磁盘 IO

iotop

3. 带宽占用

iftop

监控端口 21:

iftop -i eth0

五、自动化监控(推荐)

1. 使用 Monit

安装:

apt install monit

示例配置 /etc/monit/conf.d/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

启动:

systemctl restart monit

2. 使用 Zabbix / Prometheus

  • 监控指标:
    • 端口 21 存活
    • 进程状态
    • 连接数
    • 日志中的失败登录

六、安全监控(非常重要)

1. 监控暴力破解

grep "FAILED LOGIN" /var/log/vsftpd.log

2. 使用 fail2ban

apt install fail2ban

配置:

/etc/fail2ban/jail.local
[vsftpd]
enabled = true
port = ftp
logpath = /var/log/vsftpd.log

七、如果你用的是其他 FTP 服务

FTP 服务 日志位置
ProFTPD /var/log/proftpd/
Pure-FTPd /var/log/syslog

如果你能告诉我:

  • 使用的 FTP 软件
  • 是内网还是公网
  • 是否需要告警或图形化监控

我可以给你更精确的方案。

0