说明
系统:CentOS Linux release 7.1.1503 (Core) 64bit minimal
安装源
yum install wget -y
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
rpm -Uvh http://mirrors.ustc.edu.cn/centos/7.1.1503/extras/x86_64/Packages/epel-release-7-5.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum makecache
安装vsftpd
-
安装
yum install vsftpd -y
-
启动
systemctl start vsftpd
-
设置开机启动
systemctl enable vsftpd
-
重启
systemctl restart vsftpd
-
停止
systemctl stop vsftpd
配置
-
编辑配置文件
vi /etc/vsftpd/vsftpd.conf listen=YES anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 anon_upload_enable=NO anon_mkdir_write_enable=NO dirmessage_enable=YES xferlog_enable=YES xferlog_file=/var/log/vsftpd.log xferlog_std_format=YES connect_from_port_20=YES chown_uploads=NO idle_session_timeout=600 data_connection_timeout=120 nopriv_user=ftp async_abor_enable=NO ascii_upload_enable=YES ascii_download_enable=YES ftpd_banner=Test Vsftpd Server chroot_list_enable=NO ls_recurse_enable=NO pam_service_name=vsftpd userlist_enable=YES userlist_deny=YES tcp_wrappers=NO guest_enable=YES guest_username=ftp virtual_use_local_privs=YES user_config_dir=/etc/vsftpd/vconf allow_writeable_chroot=YES
-
创建文件
echo ftp >> /etc/vsftpd/chroot_list touch /var/log/vsftpd.log
-
虚拟用户配置
-
安装Berkeley DB工具
yum install db4 db4-utils -y
-
创建用户密码文件 vi /etc/vsftpd/password testuser1 password1 testuser2 password2
-
生成db文件
db_load -T -t hash -f /etc/vsftpd/password /etc/vsftpd/password.db
-
编辑认证文件 cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak vi /etc/pam.d/vsftpd auth required pam_userdb.so db=/etc/vsftpd/password account required pam_userdb.so db=/etc/vsftpd/password
-
创建虚拟用户testuser1的配置文件
mkdir -p /etc/vsftpd/vconf vi /etc/vsftpd/vconf/testuser1 local_root=/data/ftp/testuser1 write_enable=YES anon_umask=022 anon_world_readable_only=NO anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES
-
创建虚拟用户testuser1的目录 mkdir -p /data/ftp/testuser1 chown -R ftp:ftp /data/ftp
-
启动vsftpd
systemctl start vsftpd
防火墙设置
firewall-cmd --permanent --add-service=ftp
firewall-cmd --reload
设置SElinux关于ftp
-
查看 sestatus -b| grep ftp
-
设置
setsebool allow_ftpd_full_access on