#!/bin/bash#install vsftpd and ftp#作者:iBosea#Version 3.0.2#关闭安全机制setenforce 0#check user = admin(root)if [ $(id -u) == 0 ]then echo "is root"else echo "请使用root用户登录" exit 0fi#Stop firewalldsystemctl stop firewalld.servicesystemctl disable firewalld.service#installing vsftpd and ftpyum -y install vsftpdyum -y install ftp#alter vsftpd configure fileCONFIG="/etc/vsftpd/vsftpd.conf"sed -i '/^anonymous_enable/s/YES/NO/g' $CONFIGsed -i '/^local_enable/s/NO/YES/g' $CONFIGsed -i '/^listen/s/NO/YES/g' $CONFIGsed -i '/^listen_ipv6/s/YES/NO/g' $CONFIGsed -i '/^userlist_enable/s/YES/NO/g' $CONFIG#add default ftp userUSERS="/etc/vsftpd/user_list"rm -rf $USERStouch $USERSuseradd -s /sbin/nologin ftpuserecho "ftpuser@123" >passwd.txtpasswd --stdin demo < passwd.txt &>/dev/nullecho "ftpuser" >$USERSrm -rf passwd.txt#start vsftpdsystemctl start vsftpd#输出结果ST=$(netstat -napt |grep 21 |awk '{print $6}')echo "FTP服务器状态:$ST"echo "FTP地址:$(ifconfig eth0 |grep inet |grep -v "inet6" |awk '{print echo "ftp://" $2 echo ":21"}')"echo "FTP实例用户:ftpuser 密码:ftpuser@123"echo "如果您要删除实例用户,或添加,请新建一个系统用户,然后编辑/etc/vsftpd/user_list文件,一行一个用户