#/bin/bash

yum  install vsftpd  db4-utils -y
 
if [ `uname -m | grep "x86_64"` ];then
        X86=1
        mv /etc/pam.d/vsftpd  /etc/pam.d/vsftpd.bak
echo  "auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login" >/etc/pam.d/vsftpd
echo  "account required /lib64/security/pam_userdb.so  db=/etc/vsftpd/vsftpd_login" >>/etc/pam.d/vsftpd
fi
 
if [ `uname -m | grep "i686"` ];then
        i686=1  
        cp /etc/pam.d/vsftpd  /etc/pam.d/vsftpd.bak
echo  "auth required /lib/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login" >/etc/pam.d/vsftpd
echo  "account required /lib/security/pam_userdb.so  db=/etc/vsftpd/vsftpd_login" >>/etc/pam.d/vsftpd
fi
 
cp /etc/vsftpd/vsftpd.conf  /etc/vsftpd/vsftpd.conf.bak
cat > /etc/vsftpd/vsftpd.conf <<EOF
anonymous_enable=no
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
anon_upload_enable=no
anon_mkdir_write_enable=no
chroot_list_enable=YES
virtual_use_local_privs=YES
chroot_list_file=/etc/vsftpd/chroot_list
chroot_local_user=yes
guest_enable=yes
guest_username=ftpuser
user_config_dir=/etc/vsftpd/user_config_dir
pasv_promiscuous=YES
EOF
#####################
mkdir /etc/vsftpd/user_config_dir/
cat >/etc/vsftpd/user_config_dir/add.txt <<EOF
anon_upload_enable=yes
virtual_use_local_privs=YES
chmod_enable=YES
anon_world_readable_only=no
anon_mkdir_write_enable=yes
anon_other_write_enable=yes
local_umask=023
EOF
#######
echo  "vsftpd   is ok.... do add your user use vsftpadd.sh"
#################
脚本还需根据实际环境手动添加   useradd -d /$ftpuserhome  -G /$ftpusergroup   -s /sbin/nologin    ftpuser