一篇文章了解开源 FTP 服务器 vsftpd

简介: 一篇文章了解开源 FTP 服务器 vsftpd

1 背景

某客户现场,每天都会批量生成大量 CSV 文件存放到 FTP 系统,这些 CSV 文件需要导入到大数据平台 HIVE 数仓中做后续离线分析,且 HIVE 数仓中的离线分析作业目前是使用 JENKINS 来调度的。

由于这些 CSV 文件是每天都会生成,且文件数比较多数据量也比较大,初步计划使用 DATAX 来导入 FTP 上的 CSV 文件。

但在调度系统 JENKINS 中,如何检测 ftp 上的 csv 文件是否 ready,并及时触发 DATAX 导入作业,成为了一个问题。

为探索和验证 JENKINS 中 FTP 文件的检测和触发机制,笔者搭建了 FTP 服务器。

在此通过系列文章,跟大家分享一个开源的 FTP 服务器 vsftpd, 介绍下其安装配置和使用,然后介绍下 FTP 的 ACTIVE 与 PASSIVE 模式,最后介绍下 CurlFtpFS.

本片文章是系列文章第一篇,介绍下开源的 FTP 服务器 vsftpd,及其安装配置和使用。

2 开源 FTP 服务器 vsftpd 介绍

vsftpd 是一款 UNIX/LINUX 上的 FTP 服务器软件,号称是“ Probably the most secure and fastest FTP server for UNIX-like systems”,其具有以下特点:

  • 安全
  • 快速
  • 稳定
  • 开源 (基于 GPLv2 协议开源)

更多关于 vsftpd 的介绍,可以参考官网:

image.png

3 开源 FTP 服务器 vsftpd 的安装配置和管理

  • 绝大多数 linux 发行版服务器的包管理工具中都自带了 vsftpd 的安装包,直接使用包管理工具的安装命令进行安装即可;
  • 使用包管理工具安装完毕 vsftpd 后,即可使用系统服务 systemd 对 vsftpd 进行启停等常规运维管理;
  • 使用包管理工具安装完毕 vsftpd 后,需要针对自己的环境对配置文件进行修改,配置文件地址一般为 /etc/vsftpd/vsftpd.conf

image.png

以下以 aws ec2 为例,介绍下 vsftpd 的安装和配置要点。

  • yum install vsftpd //安装
  • systemctl start/stop/restart/status vsftpd //启停管理
  • systemctl enable vsftpd //配置开机自启

相关截图:

image.png

image.png

image.png

改配置文件/etc/vsftpd/vsftpd.conf,重要的更改项如下:

  • anonymous_enable=NO // 关闭匿名用户登录
  • local_enable=YES //允许本地系统用户(/etc/passwd 中的用户)登录
  • write_enable=YES //允许对文件系统的写操作,比如上传文件,删除文件
  • chroot_local_user=YES //开启 chroot jail 以增强安全性,开启后本地系统用户登录后会被 jail 到其 home directory
  • listen=YES //开启后, vsftpd 在 stanadalone 模式下运行且监听 IPv4 地址,不受 inetd 等管理
  • listen_ipv6=NO //关闭 ipv6 地址监听
  • pasv_enable=YES // 开启 PASSIVE 模式
  • pasv_min_port=1024 //PASSIVE 模式下最小可用端口号
  • pasv_max_port=1048 //PASSIVE 模式下最大可用端口号
  • pasv_address=http://18.219.xxx.xxx //// PASSIVE 模式下对客户端广播的地址,AWS ec2 中需要使用公网 IP 不能使用内网 IP
  • allow_writeable_chroot=true // 允许用户对 chroot jail 的目录的写权限

以下几点需要注意:

  • 为简便起见,这里没有配置启用ssl: ssl_enable=NO
  • 如果没有配置参数 allow_writeable_chroot=true 以允许用户对 chroot jail 的目录的写权限,客户端访问时可能会遇到以下错误: Error message "500 OOPS: vsftpd: refusing to run with writable root inside chroot()" - keep user jailed
  • 参数 pasv_address 在 AWS ec2 中需要使用公网 IP,不能使用内网 IP,且默认情况下 AWS ec2 重启时(reboot) 其公网 IP 不会改变,但其它操作会改变其公网 ip (比如 stop 然后start);

image.png

4 vsftpd 配置文件 /etc/vsftpd/vsftpd.conf 的重要配置项说明

几项重要参数的说明如下,完整的配置项及其说明,可以通过以下命令查看官方手册: man vsftpd.conf

chroot_local_user
If set to YES, local users will be (by default) placed in a chroot() jail in their home directory after login. Warning: This option has security implications, especially if the users have upload permission, or shell access. Only enable if you know what you are doing. Note that these security implications are not vsftpd specific. They apply to all FTP daemons which offer to put local users in chroot() jails.
Default: NO
chroot_list_enable
If activated, you may provide a list of local users who are placed in a chroot() jail in their home directory upon login. The meaning is slightly different if chroot_local_user is set to YES. In this case, the list becomes a list of users which are NOT to be placed in a chroot() jail. By default, the file containing this list is /etc/vsftpd/chroot_list, but you may override this with the chroot_list_file setting.
Default: NO
chroot_list_file
The option is the name of a file containing a list of local users which will be placed in a chroot() jail in their home directory. This option is only relevant if the option chroot_list_enable is enabled. If the option chroot_local_user is enabled, then the list file becomes a list of users to NOT place in a chroot() jail.
Default: /etvsftpd.confc/vsftpd.chroot_list
allow_writeable_chroot
Allow chroot()'ing a user to a directory writable by that user. Note that setting this to YES is potentially dangerous. For example, if the user creates an 'etc' directory in the new root directory, they could potentially trick the C library into loading a user-created configuration file from the /etc/ directory.
Default: NO
local_root
This option represents a directory which vsftpd will try to change into after a local (i.e. non-anonymous) login. Failure is silently ignored.
Default: (none)
local_enable
Controls whether local logins are permitted or not. If enabled, normal user accounts in /etc/passwd (or wherever your PAM config references) may be used to log in. This must be enable for any non-anonymous login to work, including virtual users.
Default: NO
pasv_address
Use this option to override the IP address that vsftpd will advertise in response to the PASV command. Provide a numeric IP address, unless pasv_addr_resolve is enabled, in which case you can provide a hostname which will be DNS resolved for you at startup.
Default: (none - the address is taken from the incoming connected socket)

5 vsftpd 的使用

在确保服务端 vsftpd 配置正确,且正常启动的情况下,即可通过各种 ftp 客户端来使用 vsftpd。

image.png

以下截图展示了通过 wget 命令行下载 vsftpd 上指定文件:

image.png

在使用 FileZilla 图形客户端访问 aws ec2 中的 vsftpd 服务时,需要配置 active 和 passive 模式使用外网地址,如下如所示:

image.png

image.png

以下截图展示了通过 FileZilla 访问 vsftpd:

image.png

关于 FTP 的 ACTIVE 与 PASSIVE 模式,敬请期待下一篇博文。

目录
打赏
0
0
0
0
3662
分享
相关文章
FastAPI开发者福音!FastAPI-MCP:将FastAPI秒变MCP服务器的开源神器,无需配置自动转换!
FastAPI-MCP是一款能将FastAPI应用端点自动转换为符合模型上下文协议(MCP)的开源工具,支持零配置自动发现接口并保留完整文档和模式定义。
2312 71
FastAPI开发者福音!FastAPI-MCP:将FastAPI秒变MCP服务器的开源神器,无需配置自动转换!
2025年GitHub平台上的十大开源MCP服务器汇总分析
本文深入解析了GitHub上十个代表性MCP(Model Context Protocol)服务器项目,探讨其在连接AI与现实世界中的关键作用。这些服务器实现了AI模型与应用程序、数据库、云存储、项目管理等工具的无缝交互,扩展了AI的应用边界。文中涵盖Airbnb、Supabase、AWS-S3、Kubernetes等领域的MCP实现方案,展示了AI在旅行规划、数据处理、云存储、容器编排等场景中的深度应用。未来,MCP技术将向标准化、安全性及行业定制化方向发展,为AI系统集成提供更强大的支持。
1109 2
2025年GitHub平台上的十大开源MCP服务器汇总分析
在Ubuntu系统下使用vsftpd配置FTP服务器的步骤
以上就是在Ubuntu系统下使用vsftpd配置FTP服务器的步骤。这些步骤都是基础的,但足够让你建立一个简单的FTP服务器。如果你需要更高级的功能,例如SSL加密、虚拟用户等,你可能需要进一步研究vsftpd的配置选项。
257 13
GitHub 热门开源运维工具 Websoft9:如何实现服务器管理效率翻倍?
Websoft9 提供 200+ 开源应用一键部署,支持容器化隔离、GitOps 自动化和企业级安全防护,助力服务器管理效率提升 80%。
168 1
2024 主流的开源服务器面板推荐
随着云计算和虚拟专用服务器(VPS)的普及,服务器面板工具成为了企业和个人管理服务器的得力助手。一个优秀的服务器面板不仅可以简化服务器管理任务,还可以提升工作效率和安全性。本文将为您介绍并测评几款2024年全网热门的服务器面板,包括Websoft9、宝塔、cPanel、1Panel等,帮助您找到最适合自己的管理工具。
2024 主流的开源服务器面板推荐
深入解析与防范:基于缓冲区溢出的FTP服务器攻击及调用计算器示例
本文深入解析了利用缓冲区溢出漏洞对FTP服务器进行远程攻击的技术,通过分析FreeFlow FTP 1.75版本的漏洞,展示了如何通过构造过长的用户名触发缓冲区溢出并调用计算器(`calc.exe`)。文章详细介绍了攻击原理、关键代码组件及其实现步骤,并提出了有效的防范措施,如输入验证、编译器保护和安全编程语言的选择,以保障系统的安全性。环境搭建基于Windows XP SP3和Kali Linux,使用Metasploit Framework进行攻击演示。请注意,此内容仅用于教育和研究目的。
237 4
服务器管理面板大盘点: 8款开源面板助你轻松管理Linux服务器
在数字化时代,服务器作为数据存储和计算的核心设备,其管理效率与安全性直接关系到业务的稳定性和可持续发展。随着技术的不断进步,开源社区涌现出众多服务器管理面板,这些工具以其强大的功能、灵活的配置和友好的用户界面,极大地简化了Linux服务器的管理工作。本文将详细介绍8款开源的服务器管理面板,包括Websoft9、宝塔、cPanel、1Panel等,旨在帮助运维人员更好地选择和使用这些工具,提升服务器管理效率。
基于阿里云服务器Linux系统安装Docker完整图文教程(附部署开源项目)
基于阿里云服务器Linux系统安装Docker完整图文教程(附部署开源项目)
1944 3
一个.NET开源、快速、低延迟的异步套接字服务器和客户端库
一个.NET开源、快速、低延迟的异步套接字服务器和客户端库
187 4
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等

登录插画

登录以查看您的控制台资源

管理云资源
状态一览
快捷访问