vsftpd一键安装配置脚本,可配合 lnmp1.0 使用(为lnmp1.0而扩展编写)。
接受用户输入ftp指定的用户名密码,可锁定用户家目录为nginx站点默认根目录,比如/usr/local/nginx/html 。在开启iptables服务时,需手动修改iptables,放行21、30000到30100端口。
下载地址:https://www.rootop.org/rs/onekey/install_vsftpd1.0.sh 推荐wget方式下载。
安装方法:
sh install_vsftpd1.0.sh #适用于新系统,没有安装过vsftpd的机器
SourceCode:
#!/bin/bash #Create By : www.rootop.org #MailAddress: venus@rootop.org #Version : install_vsftpd1.0 #Data : 2014/10/30 #Desc : for yum version #Tested : CentOS6 # install vsftpd service yum install -y vsftpd clear echo -e "\033[31m vsftpd service install done\033[0m" echo "----------------------------------------------" # add system user map to virtual user #useradd -s /sbin/nologin vuser cd /etc/vsftpd/ cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak read -p "pls input a username: " user echo "----------------------------------------------" read -p "pls input a password: " pass echo "----------------------------------------------" echo -e "\033[31m whitch directory would u wanna to lock in? input full path. for example: /usr/local/nginx/html\033[0m" echo -e "\033[31m the last character don't be end with /. use ctrl+c to go back command line. \033[0m" echo "----------------------------------------------" read -p "pls input a full path: " dire echo "----------------------------------------------" echo "your username is \"$user\" ,password is \"$pass\" , directory is \"$dire\" ." echo "----------------------------------------------" echo "initializaton vsftpd configuraton" echo "----------------------------------------------" # add virtual user from user in put echo $user > vuser && echo $pass >> vuser # create database file db_load -T -t hash -f /etc/vsftpd/vuser /etc/vsftpd/vuser.db # open virtual user echo guest_enable=yes >> vsftpd.conf # set map to system user echo guest_username=www >> vsftpd.conf # set vuser profile directory echo user_config_dir=/etc/vsftpd/user_config >> vsftpd.conf # set passive modu and port echo pasv_enable=YES >> vsftpd.conf echo pasv_min_port=30000 >> vsftpd.conf echo pasv_max_port=30100 >> vsftpd.conf # set pam mv /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak touch /etc/pam.d/vsftpd if [ "$(uname -a | grep x86_64 | wc -l)" == "1" ]; then cat >/etc/pam.d/vsftpd<<EOF auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser EOF else cat >/etc/pam.d/vsftpd<<EOF auth required /lib/security/pam_userdb.so db=/etc/vsftpd/vuser account required /lib/security/pam_userdb.so db=/etc/vsftpd/vuser EOF fi # make directory for vuser mkdir user_config cd user_config touch $user cat >$user<<EOF local_root=$dire download_enable=yes anon_upload_enable=yes anon_mkdir_write_enable=yes anon_other_write_enable=yes local_umask=022 anon_umask=022 file_open_mode=0755 EOF chown -R www:www $dire if [ "$(echo $?)" == "0" ]; then echo "change permission for $dire done" echo "----------------------------------------------" else echo -e "\033[31m change permission for $dire false\033[0m" echo -e "\033[31m install ignore\033[0m" exit fi echo "config vsftpd done" echo "----------------------------------------------" if [ "$(ps aux | grep vsftpd | grep -v "grep" | wc -l)" == "1" ]; then service httpd restart && chkconfig vsftpd on echo "----------------------------------------------" else service vsftpd start && chkconfig vsftpd on echo "----------------------------------------------" fi echo -e "\033[31m if your iptables is open ,pls accept 21,30000-30100 port\033[0m" echo "----------------------------------------------" echo "vsftpd install done" echo "----------------------------------------------" exit
如果作为单独安装,需要修改:
#useradd -s /sbin/nologin vuser
去掉前面注释
echo guest_username=www >> vsftpd.conf
www改为vuser
chown -R www:www $dire
www:www改为vuser:vuser
原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/3031.html