第一步 ftp 服务安装
查看是否安装 ftp
rpm -qa|grep vsftpd
没有 执行
yum install -y vsftpd
安装完成 进入 /etc/vsftpd 进行配置
vsftpd.conf vsftpd 核心配置文件
ftpusers 黑名单
user_list 白名单
注销 /etc/pam.d/vsftpd 对应的 pam_shells.so
vi /etc/pam.d/vsftpd
#auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/user_list onerr=succeed
#auth required pam_shells.so
useradd fyj
passwd fyj 回车 依次输入密码 确认密码
备注: 本地用户和对应的文件目录可有程序控制
启动ftp
systemctl restart vsftpd.service
我的服务配置
cd /etc/vsftpd/
vi vsftp.conf
# 禁止匿名用户登陆
anonymous_enable=NO
write_enable=YES
pasv_enable=YES
pasv_min_port=24500
pasv_max_port=24600
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
download_enable=YES
chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
listen_address=120.26.147.187
pam_service_name=vsftpd
userlist_enable=YES
userlist_deny=NO
tcp_wrappers=NO
allow_writeable_chroot=YES
user_config_dir=/etc/vsftpd/userconf
vi user_list
fyj
demo
第二步 监听ftp 服务器文件变化
inotify-tool install
yum install inotify-tools -y
创建监听事件 inotify.sh
#!/bin/bash
#filename watchdir.sh
# 方式1 发送监听日志到到远程API进行处理
inotifywait -mrqs -e delete,create --fromfile '/etc/vsftpd/inotifyFile' --timefmt '%Y-%m-%d-%H:%M:%S' --format '%T_%w_%f_%e' /etc/vsftpd/userfile/ | while read file;
do
curl xxxx?canshu=${file}
done
# 方式2 发送监听日志到文件
inotifywait -mrqs -e delete,create --fromfile '/etc/vsftpd/inotifyFile' --timefmt '%Y-%m-%d-%H:%M:%S' --format '%T_%w_%f_%e' /etc/vsftpd/userfile/ >> /tmp/rsync.txt
# 因为业务需求 我暂时使用 方式1 方便处理文件内容
第三步 处理 文件变化日志 具体就不列出