在 Ubuntu 上实现 FTPS(FTP over SSL/TLS)加密,最常用、稳定的方案是使用 vsftpd + SSL/TLS。下面按步骤说明。
如果你要的是“加密的 FTP”,那就是 FTPS,下面以 vsftpd 为例。
sudo apt update
sudo apt install vsftpd
sudo openssl req -x509 -nodes -days 365 \
-newkey rsa:2048 \
-keyout /etc/ssl/private/vsftpd.key \
-out /etc/ssl/certs/vsftpd.crt
sudo chmod 600 /etc/ssl/private/vsftpd.key
生产环境建议使用 Let’s Encrypt 证书
编辑配置文件:
sudo nano /etc/vsftpd.conf
listen=YES
listen_ipv6=NO
anonymous_enable=NO
local_enable=YES
write_enable=YES
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
rsa_cert_file=/etc/ssl/certs/vsftpd.crt
rsa_private_key_file=/etc/ssl/private/vsftpd.key
require_ssl_reuse=NO
require_ssl_reuse=NO可避免部分客户端失败
云服务器必须配置被动端口:
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=41000
pasv_address=你的服务器公网IP
sudo systemctl restart vsftpd
sudo systemctl enable vsftpd
sudo ufw allow 21/tcp
sudo ufw allow 40000:41000/tcp
ftp://你的IP21✅ 禁用匿名
✅ 使用强密码 / 虚拟用户
✅ 使用 Let’s Encrypt 证书
✅ 限制 IP 或配合 Fail2Ban
如果你需要:
可以继续问我。