要在 Ubuntu 24.04 上设置 FTP 服务器,请按照以下步骤操作:
步骤 1:首先更新软件包列表,以确保获取到最新版本。
sudo apt update

步骤 2:安装 vsftpd FTP 服务器软件包。
sudo apt install vsftpd

步骤 3:安装完成后,检查 vsftpd 的状态以确认其正在运行。
systemctl status vsftpd

步骤 4:编辑 vsftpd 配置文件,禁用匿名 FTP 访问并配置其他设置。
sudo nano /etc/vsftpd.conf
设置以下选项:
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
user_sub_token=$USER
local_root=/home/$USER
allow_writeable_chroot=YES

步骤 5:重启 vsftpd 服务以使更改生效。
sudo systemctl restart vsftpd

步骤 6:使用 adduser 命令创建一个用于访问 FTP 服务器的用户。
sudo adduser ftpuser

步骤 7:如果启用了 UFW,请允许 FTP 流量。
sudo ufw allow 20/tcp
sudo ufw allow 21/tcp

步骤 8:现在,使用 FileZilla 等 SFTP 客户端测试 FTP 连接。
- 打开 SFTP 客户端(FileZilla)

- 添加站点

- 在“主机”字段中,输入安装了 vsftpd 的 Ubuntu 服务器的 IP 地址或主机名。
- 将“端口”设置为 21(默认 FTP 端口)。
- 选择“FTP - 文件传输协议”作为协议。
- 从“加密”下拉菜单中,选择“如果可用,则使用基于 TLS 的显式 FTP”。
- 将“登录类型”设置为“正常”。
- 输入您在步骤 6 中创建的 FTP 用户的用户名和密码。
- 连接

恭喜!您已在 Ubuntu 24.04 系统上成功设置并配置了 vsftpd FTP 服务器。