在 Ubuntu 上启动 FTP 服务器(通常指 vsftpd,支持 FTP/FTPS),可以按下面步骤来。
sudo apt update
sudo apt install vsftpd
sudo systemctl start vsftpd
sudo systemctl enable vsftpd
查看状态:
sudo systemctl status vsftpd
看到 active (running) 说明已启动。
配置文件路径:
sudo nano /etc/vsftpd.conf
# 允许本地用户登录
local_enable=YES
# 允许上传
write_enable=YES
# 禁止匿名登录
anonymous_enable=NO
# 限制用户只能访问自己的 home 目录(可选)
chroot_local_user=YES
allow_writeable_chroot=YES
保存后重启:
sudo systemctl restart vsftpd
FTP 默认使用 21 端口:
sudo ufw allow 21/tcp
sudo ufw reload
如果你启用了被动模式(推荐),还需要开放被动端口范围,例如:
# /etc/vsftpd.conf
pasv_enable=YES
pasv_min_port=30000
pasv_max_port=31000
防火墙:
sudo ufw allow 30000:31000/tcp
sudo useradd -m ftpuser
sudo passwd ftpuser
ftp localhost
或使用 FileZilla / WinSCP 连接:
生成证书并修改配置:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/ssl/private/vsftpd.key \
-out /etc/ssl/certs/vsftpd.crt
在 vsftpd.conf 中加入:
ssl_enable=YES
rsa_cert_file=/etc/ssl/certs/vsftpd.crt
rsa_private_key_file=/etc/ssl/private/vsftpd.key
重启服务即可。
local_enable、write_enablewrite_enable=YES如果你需要我帮你:
直接把你的 Ubuntu 版本和报错信息发我即可。