Centos 7 vsftpd安装与配置

关闭linux防火墙 ,关闭SELINUX。在进行以下操作

#安装
yum install -y vsftpd

#设置开机启动
systemctl enable vsftpd.service

#启动
systemctl start vsftpd.service

#停止
systemctl stop vsftpd.service

#查看状态
systemctl status vsftpd.service

配置FTP

#打开配置文件
vim /etc/vsftpd/vsftpd.conf

#显示行号
:set number

#修改配置 12 行
anonymous_enable=NO

#修改配置 33 行
anon_mkdir_write_enable=YES

#修改配置48行
chown_uploads=YES

#修改配置72行
async_abor_enable=YES

#修改配置82行
ascii_upload_enable=YES

#修改配置83行
ascii_download_enable=YES

#修改配置86行
ftpd_banner=Welcome to blah FTP service.#修改配置100行chroot_local_user=YES

#添加下列内容到vsftpd.conf末尾
use_localtime=YES
listen_port=21
idle_session_timeout=300
guest_enable=YES
guest_username=vsftpd
user_config_dir=/etc/vsftpd/vconf
data_connection_timeout=1
virtual_use_local_privs=YES
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=40010
accept_timeout=5
connect_timeout=1allow_writeable_chroot=YES

建立用户文件

#创建编辑用户文件
vim /etc/vsftpd/virtusers
#第一行为用户名,第二行为密码。不要使用root作为用户名 

cherish
123123

生成用户数据文件

db_load -T -t hash -f /etc/vsftpd/virtusers /etc/vsftpd/virtusers.db

#设定PAM验证文件,并指定对虚拟用户数据库文件进行读取

chmod 600 /etc/vsftpd/virtusers.db 

修改 /etc/pam.d/vsftpd 文件

vi /etc/pam.d/vsftpd
#先将配置文件中原有的 auth 及 account 的所有配置行均注释掉
auth sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers 
account sufficient /lib64/security/pam_userdb.so db=/etc/vsftpd/virtusers
#如果系统为32位,上面改为lib

新建系统用户vsftpd,用户目录为/home/vsftpd/cherish

#用户登录终端设为/bin/false(即:使之不能登录系统)
useradd vsftpd -d /home/vsftpd -s /bin/false
chown -R vsftpd:vsftpd /home/vsftpd/cherish
#vsftpd 这里的不是用ftp户名 不要更改

建立虚拟用户个人配置文件

mkdir -p /etc/vsftpd/vconf

cd /etc/vsftpd/vconf

#这里建立虚拟用户cherish配置文件
touch cherish

#编辑cherish用户配置文件,内容如下,其他用户类似
vim cherish
#限定访问目录
local_root=/home/vsftpd/cherish/
write_enable=YES
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES

#建立cherish用户根目录
mkdir -p /home/vsftpd/cherish
#赋予权限
chmod -R 777 /home/vsftpd/cherish

重启vsftpd服务器

systemctl restart vsftpd.service

使用ftp工具连接测试

Ftp工具FileZilla 打开主动模式,在进行访问不然提示读取目录失败。

努力学习java的Cherish
原文地址:https://www.cnblogs.com/cherish-code/p/14905900.html