1. useradd -s /bin/bash -m 用户名 , 创建用户,自动创建家目录 , 设置登录shell
2. echo 用户名:密码 | chpasswd ,非交互式设置密码
3. echo -e "userlist_deny=NOnuserlist_enable=YESnuserlist_file=/etc/allowed_usersnseccomp
_sandbox=NO" >> /etc/vsftpd.conf , 往配置文件中追加配置 , 保留换行符
4. sed '/$NAME/d' /etc/ftpusers" , 修改某项配置的值
ubuntu 系统 16.04
代码语言:javascript复制#!/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=NOnuserlist_enable=YESnuserlist_file=/etc/allowed_use
rsnseccomp_sandbox=NO' > /etc/vsftpd.conf"
echo -e "userlist_deny=NOnuserlist_enable=YESnuserlist_file=/etc/allowed_usersnseccomp
_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 "=====安装成功!==============================";