环境:RHEL_5.6 x86_64.iso
#!/bin/bash
yum install vsftpd
echo guest_username=www-data >>/etc/vsftpd/vsftpd.conf
echo user_config_dir=/etc/vsftpd_user_conf >>/etc/vsftpd/vsftpd.conf
echo virtual_use_local_privs=YES >>/etc/vsftpd/vsftpd.conf
echo chroot_local_user=YES >>/etc/vsftpd/vsftpd.conf
echo deny_file='{*_notes,*.svn,*.db,*.LCK,*.lsz}' >>/etc/vsftpd/vsftpd.conf
yum --nogpgcheck install db4*
cd /etc/
touch ftpuser.txt
mkdir vsftpd_user_conf
echo -e 'xiao -nxiao' > ftpuser.txt
db_load -T -t hash -f /etc/ftpuser.txt /etc/vsftpd_login.db
chmod 600 /etc/vsftpd_login.db
cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak
echo -e 'auth required /lib64/security/pam_userdb.so db=/etc/vsftpd_login \naccount required /lib64/security/pam_userdb.so db=/etc/vsftpd_login' > /etc/pam.d/vsftpd
cd
cd /etc/vsftpd_user_conf/
#建立虚拟用户配置文件
echo "请输入用户名:"
read name
touch $name
echo -e 'write_enable=YES \nanon_world_readable_only=NO \nanon_upload_enable=YES \nanon_mkdir_write_enable=YES \nanon_other_write_enable=YES \nchown_uploads=YES \nchown_username=www-data \nlocal_root=/var/www/www.xiaoxiao.com/' > $name
重启服务
service vsftpd restart