配置 CentOS FTP 服务器的被动模式需要以下几个步骤:
在 CentOS 上安装 vsftpd,可以使用以下命令:
sudo yum install vsftpd
安装完成后,启动 vsftpd 服务并设置为开机自启:
sudo systemctl start vsftpd
sudo systemctl enable vsftpd
编辑 vsftpd 的配置文件 /etc/vsftpd/vsftpd.conf
,找到以下设置并进行修改:
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
allow_writeable_chroot=YES
anonymous_enable=NO
:禁止匿名访问。local_enable=YES
:允许本地用户登录。write_enable=YES
:允许本地用户上传文件。chroot_local_user=YES
:将本地用户限制在其主目录中。allow_writeable_chroot=YES
:允许 chroot 目录可写(这是为了解决在某些情况下,用户可能无法写入其主目录的问题)。在 /etc/vsftpd/vsftpd.conf
文件中,添加或修改以下设置以配置被动模式端口范围:
pasv_enable=YES
pasv_min_port=50000
pasv_max_port=60000
这里设置了被动模式的端口范围为 50000 到 60000。你可以根据需要调整这些值。
保存配置文件后,重启 vsftpd 服务以应用更改:
sudo systemctl restart vsftpd
现在,你的 CentOS FTP 服务器已经配置为被动模式。客户端在连接到服务器时,将自动进入被动模式进行数据传输。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:centos vsftp如何配置被动模式