1.  useradd -s /bin/bash -m 用户名 ,  创建用户,自动创建家目录 , 设置登录shell

 2.  echo 用户名:密码 | chpasswd ,非交互式设置密码

 3. echo -e "userlist_deny=NO\nuserlist_enable=YES\nuserlist_file=/etc/allowed_users\nseccomp

保留换行符

 4. sed '/$NAME/d' /etc/ftpusers"  , 修改某项配置的值

 ubuntu 系统 16.04

#!/bin/bash
echo -e "=====安装FTP服务=========================\n";
echo "请输入用户名:";
read NAME;
echo "请输入密码:";
read PASSWORD;
echo "执行 useradd -s /bin/bash -m $NAME";
useradd  -s /bin/bash -m $NAME
echo "执行 echo $NAME:$PASSWORD | chpasswd";
echo $NAME:$PASSWORD | chpasswd
echo "执行 apt-get install vsftpd -y"
apt-get install vsftpd -y
echo "执行 echo -e 'userlist_deny=NO\nuserlist_enable=YES\nuserlist_file=/etc/allowed_use
rs\nseccomp_sandbox=NO' > /etc/vsftpd.conf"
echo -e "userlist_deny=NO\nuserlist_enable=YES\nuserlist_file=/etc/allowed_users\nseccomp
_sandbox=NO" >> /etc/vsftpd.conf
echo "执行 echo '$NAME' > /etc/allowed_users"
echo "$NAME" > /etc/allowed_users
echo "执行 sed '/$NAME/d' /etc/ftpusers"
sed '/$NAME/d' /etc/ftpusers
echo "执行 service vsftpd start"
service vsftpd start
echo "=====安装成功!==============================";