本文是在虚拟用户已经建立的前提下,需要增加用户时用的脚本,方便用户的添加。
 
#! /bin/bash
 
echo "欢迎使用FTP创建程序,请输入用户名:"
read username
if [ -d /data/ftp/$username ];then
echo "该用户已存在!"
else 
echo "请输入密码:" 
read password
        echo "请再一次输入密码:"
read password2
        if [ $password != $password2 ];then
       echo "您两次输入的密码不一致!"
else
 
mkdir /data/ftp/$username
chown -R vuser:vuser /data/ftp/$username
chmod -R 700 /data/ftp/$username
 
touch /etc/vsftpd/vconf/$username
echo "guest_username=vuser">>/etc/vsftpd/vconf/$username
echo "local_root=/data/ftp/$username">>/etc/vsftpd/vconf/$username
echo "anon_world_readable_only=no">>/etc/vsftpd/vconf/$username
echo "write_enable=yes">>/etc/vsftpd/vconf/$username
echo "anon_upload_enable=yes">>/etc/vsftpd/vconf/$username
echo "anon_mkdir_write_enable=yes">>/etc/vsftpd/vconf/$username
echo "anon_other_write_enable=yes">>/etc/vsftpd/vconf/$username
echo "anon_max_rate=2000000">>/etc/vsftpd/vconf/$username
 
echo "$username">>/etc/vsftpd/vuser.txt
echo "$password">>/etc/vsftpd/vuser.txt
db_load -T -t hash -f /etc/vsftpd/vuser.txt /etc/vsftpd/vuser.db
echo "FTP帐号成功创建!"
fi
fi