CentOS7安装配置FTP

本文详细介绍了如何在Linux系统上安装并配置VSFTPD服务,包括安装软件包、设置开机自启动、修改配置文件、创建虚拟用户、设置防火墙及SELINUX等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、安装

yum install -y vsftpd

2、设置开机自启动

systemctl enable vsftpd.service

3、修改配置文件

vim /etc/vsftpd/vsftpd.conf

编辑以下内容

anonymous_enable=NO(12行)

anon_mkdir_write_enable=YES(33行)

chown_uploads=YES(48行)

async_abor_enable=YES(72行)

ascii_upload_enable=YES(83行)

ascii_download_enable=YES(84行)

ftpd_banner=Welcome to blah FTP service.(87行)

chroot_local_user=YES(101行)

listen=YES(115行)

listen_ipv6=NO(124行)

以下配置内容添加到尾部

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_min_port=40000

pasv_max_port=40010

accept_timeout=5

connect_timeout=1

allow_writeable_chroot=YES

4、创建用户

创建用户文件

vim /etc/vsftpd/virtusers

第一行为用户名 第二行为密码

allen

a12345

5、生成用户数据文件

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

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

chmod 600 /etc/vsftpd/virtusers.db

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

vim /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位,lib64改为lib

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

用户登录终端设为/bin/false(即:使之不能登录系统)

useradd vsftpd -d /home/vsftpd -s /bin/false

chown -R vsftpd:vsftpd /home/vsftpd

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

mkdir /etc/vsftpd/vconf

cd /etc/vsftpd/vconf

建立虚拟用户allen配置文件

touch allen 

编辑用户配置文件

vi allen

内容如下

local_root=/home/vsftpd/allen/

write_enable=YES

anon_world_readable_only=NO

anon_upload_enable=YES

anon_mkdir_write_enable=YES

anon_other_write_enable=YES

建立用户根目录

mkdir -p /home/vsftpd/allen/

其他用户使用类似配置

9、防火墙设置

执行设置命令

firewall-cmd --zone=public --add-service=ftp --permanent

firewall-cmd --zone=public --add-port=21/tcp --permanent

firewall-cmd --zone=public --add-port=40000-40010/tcp --permanent

10、关闭SELINUX

打开SELINUX配置文件

vim /etc/selinux/config

修改为以下配置项

SELINUX=disabled

11、设置文件夹访问权限

chmod -R 777 /home/vsftpd/allen

12、重启系统

shutdown -r now

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值