天天看點

centos vsftp 環境搭建和服務檔案監聽

第一步 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 友善處理檔案内容



第三步 處理 檔案變化日志  具體就不列出
           

繼續閱讀