Ubuntu 上 FTPS 服务器安装与配置 SSL 证书
一 准备与证书获取
sudo apt update && sudo apt install vsftpd opensslsudo apt install certbot python3-certbot-nginxsudo certbot certonly --standalone -d yourdomain.comsudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem二 配置 vsftpd 启用 SSL/TLS
sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.origsudo nano /etc/vsftpd.conf,确保包含以下关键项(按需调整)
ssl_enable=YESallow_anon_ssl=NOforce_local_logins_ssl=YESforce_local_data_ssl=YESssl_tlsv1=YESssl_sslv2=NOssl_sslv3=NOssl_ciphers=HIGHrsa_cert_file=/etc/letsencrypt/live/yourdomain.com/fullchain.pemrsa_private_key_file=/etc/letsencrypt/live/yourdomain.com/privkey.pemrsa_cert_file=/etc/ssl/private/vsftpd.pemrsa_private_key_file=/etc/ssl/private/vsftpd.pemanonymous_enable=NOlocal_enable=YESwrite_enable=YESchroot_local_user=YESallow_writeable_chroot=NOxferlog_enable=YESsudo systemctl restart vsftpdsudo systemctl enable vsftpd三 防火墙与被动模式端口
sudo ufw reload/etc/vsftpd.conf 增加:
pasv_enable=YESpasv_min_port=40000pasv_max_port=50000pasv_address=YOUR_SERVER_PUBLIC_IP(NAT/云主机建议填写公网 IP)四 客户端连接与验证
lftp -u youruser,yourpass ftps://yourdomain.com:990sudo certbot renew --dry-run 测试,加入定时任务自动续期五 常见问题与排查
pasv_address 与公网出口 IP 一致(NAT 环境)ls -l /etc/letsencrypt/live/yourdomain.com/、/etc/ssl/private/vsftpd.pemsudo journalctl -u vsftpd -xesudo apt install openssh-server,默认端口 22,用户使用 SFTP 客户端连接即可,免配 SSL 证书