在 Ubuntu 上安装 FTP 服务器,最常用的是 vsftpd(Very Secure FTP Daemon)。下面是完整安装与基本配置步骤:
sudo apt update
sudo apt install vsftpd
sudo systemctl start vsftpd
sudo systemctl enable vsftpd
sudo systemctl status vsftpd
配置文件位置:
/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
保存后重启服务:
sudo systemctl restart vsftpd
sudo adduser ftpuser
设置密码并按提示完成。
(如限制用户只能 FTP,不能登录系统,可后续设置 shell 为 nologin)
如果启用了 UFW:
sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
sudo ufw reload
如使用被动模式,还需开放被动端口范围(在配置中指定)。
本地测试:
ftp localhost
或使用 FileZilla 等客户端连接。
如果你只是想安全传文件,SFTP(基于 SSH) 更推荐,Ubuntu 默认已支持:
sftp username@server_ip
如果你需要:
可以告诉我你的具体需求。