温馨提示×

centos vsftp怎么开启

小樊
48
2026-10-26 06:57:52
栏目: 智能运维

在 CentOS 上开启并使用 vsftpd(Very Secure FTP Daemon),一般步骤如下:


一、安装 vsftpd

yum install -y vsftpd

(CentOS 8 可用 dnf install -y vsftpd)


二、启动 vsftpd 服务

systemctl start vsftpd

设置开机自启:

systemctl enable vsftpd

查看状态:

systemctl status vsftpd

三、配置防火墙

如果是 firewalld:

firewall-cmd --permanent --add-service=ftp
firewall-cmd --reload

如果是被动模式(推荐),还需放开被动端口(示例 30000-31000):

firewall-cmd --permanent --add-port=30000-31000/tcp
firewall-cmd --reload

四、基本配置(可选)

编辑配置文件:

vi /etc/vsftpd/vsftpd.conf

常见配置示例:

anonymous_enable=NO
local_enable=YES
write_enable=YES
pasv_min_port=30000
pasv_max_port=31000

修改后重启:

systemctl restart vsftpd

五、创建 FTP 用户(可选)

useradd ftpuser
passwd ftpuser

限制用户只能 FTP(不能登录系统):

usermod -s /sbin/nologin ftpuser

六、SELinux 处理(常见问题)

查看状态:

getenforce

临时关闭:

setenforce 0

永久允许 FTP:

setsebool -P ftp_home_dir on

七、测试连接

ftp localhost

或本地用 FileZilla 连接。


如果你告诉我 CentOS 版本(6/7/8) 和 用途(内网/公网、匿名/账号),我可以给你更精确的安全配置方案。

0 踩