#!/bin/bash #搭建ftp #auth find install_vsftp(){ echo "开始安装vsftp 并且检查环境" yum -y install vsftpd libdb-utils #ftp数据存放目录 mkdir /data/vsftpd -p #创建ftp用户 useradd vsftpd -d/data/vsftpd -s /bin/false echo "开始配置ftp" mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf_bak #配置数据写入到配置文件 cat >/etc/vsftpd/vsftpd.conf<<‘LWT‘ anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 anon_upload_enable=YES dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES xferlog_std_format=YES ascii_upload_enable=YES ascii_download_enable=YES chroot_local_user=YES listen=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES use_localtime=YES listen_port=21 chroot_local_user=YES idle_session_timeout=300 guest_enable=YES guest_username=vsftpd user_config_dir=/etc/vsftpd/vuserconf data_connection_timeout=5 virtual_use_local_privs=YES accept_timeout=5 connect_timeout=5 pasv_enable=YES pasv_min_port=3000 pasv_max_port=3005 allow_writeable_chroot=YES LWT cd /etc/vsftpd echo "wgftp" >/etc/vsftpd/virtusers echo "4eJ9wSpBesfKYpHv4X0eupU" >>/etc/vsftpd/virtusers db_load -T -t hash -f virtusers virtusers.db chmod 600 /etc/vsftpd/virtusers.db #centos系统位64位 echo "auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers" > /etc/pam.d/vsftpd echo "account required /lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers" >> /etc/pam.d/vsftpd #配置虚拟用户的配置文件 mkdir -p /etc/vsftpd/vuserconf cd /etc/vsftpd/vuserconf #写入用户权限配置 cat >wgftp<<‘LWT‘ local_root=/data/vsftpd write_enable=YES anon_world_readable_only=NO anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES LWT #授权目录 chow -R vsftpd.vsftpd /data/vsftpd } install_vsftp
原文:https://www.cnblogs.com/yangxiufeng/p/14406455.html