centos vsftp 环境搭建和服务文件监听

19 篇文章 0 订阅
10 篇文章 0 订阅
第一步 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 方便处理文件内容



第三步 处理 文件变化日志  具体就不列出

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值