下面以 vsftpd(Very Secure FTP Daemon) 为例,介绍在 Debian 上配置 FTP / FTPS(FTP over SSL/TLS) 的完整步骤。vsftpd 是 Debian 上最常用、最安全的 FTP 服务端。
sudo apt update
sudo apt install vsftpd -y
查看状态:
sudo systemctl status vsftpd
sudo openssl req -x509 -nodes -days 365 \
-newkey rsa:2048 \
-keyout /etc/ssl/private/vsftpd.key \
-out /etc/ssl/certs/vsftpd.crt
一路回车即可(Common Name 可填服务器 IP 或域名)。
sudo apt install certbot -y
sudo certbot certonly --standalone -d ftp.example.com
证书路径通常为:
/etc/letsencrypt/live/ftp.example.com/
编辑配置文件:
sudo nano /etc/vsftpd.conf
listen=YES
listen_ipv6=NO
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
allow_writeable_chroot=YES
ssl_enable=YES
rsa_cert_file=/etc/ssl/certs/vsftpd.crt
rsa_private_key_file=/etc/ssl/private/vsftpd.key
rsa_cert_file=/etc/letsencrypt/live/ftp.example.com/fullchain.pem
rsa_private_key_file=/etc/letsencrypt/live/ftp.example.com/privkey.pem
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
require_ssl_reuse=NO
ssl_ciphers=HIGH
pasv_enable=YES
pasv_min_port=30000
pasv_max_port=31000
pasv_address=你的服务器公网IP
sudo systemctl restart vsftpd
sudo systemctl enable vsftpd
sudo useradd -m ftpuser
sudo passwd ftpuser
禁止 SSH 登录(可选):
sudo usermod -s /usr/sbin/nologin ftpuser
sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
sudo ufw allow 30000:31000/tcp
| 类型 | 说明 |
|---|---|
| FTP | 明文(不推荐) |
| FTPS | 显式 SSL(端口 21,推荐) |
| SFTP | SSH 协议(不是 FTP,VSFTPD 不支持) |
✅ 客户端(FileZilla)选择:
sudo nano /etc/pam.d/vsftpd
pasv_address 必须正确如果你需要:
可以告诉我你的具体使用场景,我可以给你定制配置。