在 Linux 上搭建 支持 SSL/TLS 的 FTP 服务器(FTPS),常见做法是使用 vsftpd + SSL。下面以 vsftpd 为例,说明完整步骤。
# Debian / Ubuntu
sudo apt update
sudo apt install vsftpd openssl -y
# CentOS / Rocky / Alma
sudo yum install vsftpd openssl -y
sudo openssl req -x509 -nodes -days 365 \
-newkey rsa:2048 \
-keyout /etc/ssl/private/vsftpd.key \
-out /etc/ssl/certs/vsftpd.crt
⚠️ 生产环境建议使用 Let’s Encrypt 或 CA 签发证书
编辑配置文件:
sudo vim /etc/vsftpd.conf
# 启用 SSL
ssl_enable=YES
# 允许的 SSL 协议
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
# 强制使用 SSL(推荐)
force_local_logins_ssl=YES
force_local_data_ssl=YES
# 允许匿名用户不使用 SSL(可选)
allow_anon_ssl=NO
云服务器必须配置,否则连不上:
pasv_enable=YES
pasv_min_port=30000
pasv_max_port=31000
pasv_address=你的服务器公网IP
# FTP 控制端口
sudo ufw allow 21/tcp
# 被动端口范围
sudo ufw allow 30000:31000/tcp
sudo systemctl restart vsftpd
sudo systemctl enable vsftpd
主机: ftps://服务器IP
端口: 21
加密: 使用显式 FTP over TLS
pasv_addressSFTP ≠ FTPS
SFTP 是 SSH 文件传输,不需要 vsftpd
sftp user@ip
sudo apt install certbot
sudo certbot certonly --standalone -d ftp.example.com
然后修改:
rsa_cert_file=/etc/letsencrypt/live/ftp.example.com/fullchain.pem
rsa_private_key_file=/etc/letsencrypt/live/ftp.example.com/privkey.pem
如果你告诉我:
我可以给你 定制配置。