FTP服务器安装脚本分享

FTP服务安装shell脚本分享

 #!/bin/bash
 #2019年10月24日 10:57:12
 #by vftpd server
 #wangxuejin www.cnbugs.com
 
 FTP_YUM="yum install -y"
 FTP_DIR="/etc/vsftpd"
 FTP_DB="vsftpd_login"
 FTP_USR="ftpuser"
 USR_CONF="vsftpd_user_conf"
 FTP_VIR="wxjtest"
 $FTP_YUM vsftpd
 rpm -qa|grep vsftpd
 systemctl restart vsftpd.service
 $FTP_YUM  pam libdb-utils libdb --skip-broken
 touch $FTP_DIR/${FTP_USR}s.txt
 cat>$FTP_DIR/${FTP_USR}s.txt<<EOF
 $FTP_VIR
 123456
 EOF
 db_load -T -t  hash -f $FTP_DIR/${FTP_USR}s.txt $FTP_DIR/${FTP_DB}.db
 chmod 700 $FTP_DIR/${FTP_DB}.db
 cat>/etc/pam.d/vsftpd<<EOF
 auth     required    pam_userdb.so   db=$FTP_DIR/${FTP_DB}
 account    required    pam_userdb.so   db=$FTP_DIR/${FTP_DB}
 EOF
 useradd -s /sbin/nologin ${FTP_USR}
 cat>>$FTP_DIR/vsftpd.conf<<EOF
 config virtual user FTP
 pam_service_name=vsftpd
 guest_enable=YES
 guest_username=${FTP_USR}
 user_config_dir=$FTP_DIR/${USR_CONF}
 virtual_use_local_privs=YES
 EOF
 mkdir -p $FTP_DIR/${USR_CONF}/
 touch $FTP_DIR/${USR_CONF}/$FTP_VIR
 cat>$FTP_DIR/${USR_CONF}/$FTP_VIR<<EOF
 local_root=/home/${FTP_USR}/$FTP_VIR
 write_enable=YES
 anon_world_readable_only=YES
 anon_upload_enable=YES
 anon_mkdir_write_enable=YES
 anon_other_write_enable=YES
 EOF
 mkdir -p /home/${FTP_USR}/$FTP_VIR
 chown -R ${FTP_USR}:${FTP_USR} /home/${FTP_USR}
 systemctl restart vsftpd.service
 systemctl stop firewalld
 systemctl disable firewalld
 setenforce 0
 sed -i 's/enforcing/disable/g' /etc/selinux/config

发表评论

登录... 后才能评论