在 Ubuntu 上安装并配置 vsftpd(Very Secure FTP Daemon) 的步骤如下,适用于 Ubuntu 20.04 / 22.04 / 24.04。
sudo apt update
sudo apt install vsftpd -y
安装完成后,vsftpd 会自动以系统服务方式运行。
sudo systemctl start vsftpd
sudo systemctl enable vsftpd
查看状态:
sudo systemctl status vsftpd
看到 active (running) 即表示成功。
配置文件路径:
/etc/vsftpd.conf
先备份:
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
编辑配置:
sudo nano /etc/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
allow_writeable_chroot=YES
不建议直接用 root 登录 FTP。
sudo useradd -m ftpuser
sudo passwd ftpuser
设置密码后,该用户只能访问 /home/ftpuser。
sudo systemctl restart vsftpd
sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
sudo ufw reload
ftp localhost
ftp 服务器IP
或使用 FileZilla 等 FTP 客户端。
/etc/shells,确保用户 shell 存在allow_writeable_chroot=YES
pasv_enable=YES
pasv_min_port=30000
pasv_max_port=31000
并放行端口:
sudo ufw allow 30000:31000/tcp
如果你需要:
可以告诉我你的使用场景,我可以给你定制配置。