#!/bin/bash set -o errexit set -o nounset systemctl status firewalld | grep running &>/dev/null if [ $? -ne 0 ] then firewall-cmd --add-port=21/tcp --zone=public --permanent firewall-cmd --add-service=ftp firewall-cmd --reload fi yum install vsfdpd -y sed -i 's/anonymous_enable=YES/anonymous_enable=NO/' /etc/vsftpd/vsftpd.conf systemctl start vsftpd Input=$@ echo "创建默认分组: ftpgroup" groupadd ftpgroup for user in ${Input[@]} do echo "创建用户: ${user}" useradd ${user} -d /ftpdata/$user -s /sbin/nologin -G ftpgroup #useradd ${user} -s /sbin/nologin -G ftpgroup pass=$(</dev/urandom tr -dc A-Za-z0-9 | head -c12;echo) echo "设置${user}密码为: $pass" echo "${pass}" | passwd --stdin $user echo "${user} ${pass}" >> /ftpdata/info.txt echo "用户设置完成" done