在 CentOS 上开启 FTPServer(FTP 服务),常见做法是使用 vsftpd(Very Secure FTP Daemon)。下面我按 CentOS 7 / 8 / Stream 通用方式给你一个完整流程,包含安装、配置、防火墙、SELinux、启动服务。
yum install -y vsftpd
CentOS 8 / Stream 可用
dnf install -y vsftpd
systemctl start vsftpd
systemctl enable vsftpd
查看状态:
systemctl status vsftpd
配置文件路径:
/etc/vsftpd/vsftpd.conf
cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak
编辑:
vi /etc/vsftpd/vsftpd.conf
示例配置(允许本地用户登录):
# 禁止匿名登录
anonymous_enable=NO
# 允许本地用户
local_enable=YES
# 允许写操作
write_enable=YES
# 本地用户上传文件权限
local_umask=022
# 限制用户只能在自己家目录(重要)
chroot_local_user=YES
# 允许 chroot 目录可写(CentOS 7+ 必须)
allow_writeable_chroot=YES
# 监听 IPv4
listen=YES
listen_ipv6=NO
useradd ftpuser
passwd ftpuser
设置家目录(可选):
usermod -d /data/ftp ftpuser
FTP 默认使用 21 端口
firewall-cmd --permanent --add-service=ftp
firewall-cmd --reload
iptables -I INPUT -p tcp --dport 21 -j ACCEPT
service iptables save
如果 SELinux 是 enforcing,FTP 很可能连不上。
getenforce
setsebool -P ftp_home_dir on
setsebool -P allow_ftpd_full_access on
systemctl restart vsftpd
ftp localhost
ftp / lftp/etc/shells 中缺少用户 shellallow_writeable_chroot=YES
如果你要的是 加密 FTP(FTPS,不是 SFTP),可以告诉我,我给你 SSL 证书 + vsftpd SSL 配置 的完整步骤。
✅ 总结一句话
CentOS 开启 FTP Server 最常用的是
vsftpd,改配置 → 放行端口 → 处理 SELinux → 启动服务。
如果你告诉我:
我可以给你一份完全适配你环境的配置。