在Debian上集成FTPServer(FTP over SSL/TLS)可以通过多种方式实现,其中最常见的是使用vsftpd
或ProFTPD
。以下是使用这两种服务器的步骤:
安装 vsftpd
sudo apt update
sudo apt install vsftpd
配置 vsftpd
编辑 /etc/vsftpd.conf
文件:
sudo nano /etc/vsftpd.conf
确保以下配置项存在并正确设置:
listen=YES
listen_ipv6=NO
anonymous_enable=NO
local_enable=YES
write_enable=YES
chroot_local_user=YES
allow_writeable_chroot=YES
ssl_enable=YES
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
生成 SSL 证书
如果你还没有 SSL 证书,可以使用 openssl
生成自签名证书:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
重启 vsftpd
sudo systemctl restart vsftpd
配置防火墙 确保防火墙允许 FTP 和 FTPS 流量:
sudo ufw allow 21/tcp
sudo ufw allow 990/tcp
sudo ufw reload
安装 ProFTPD
sudo apt update
sudo apt install proftpd
配置 ProFTPD
编辑 /etc/proftpd/proftpd.conf
文件:
sudo nano /etc/proftpd/proftpd.conf
确保以下配置项存在并正确设置:
ServerName "ProFTPD Server"
ServerType standalone
DefaultServer on
Port 21
TLSRequired on
TLSCipherSuite HIGH:MEDIUM:+TLSv1.2
TLSCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
TLSCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
生成 SSL 证书
如果你还没有 SSL 证书,可以使用 openssl
生成自签名证书:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/ssl-cert-snakeoil.key -out /etc/ssl/certs/ssl-cert-snakeoil.pem
重启 ProFTPD
sudo systemctl restart proftpd
配置防火墙 确保防火墙允许 FTP 和 FTPS 流量:
sudo ufw allow 21/tcp
sudo ufw allow 990/tcp
sudo ufw reload
使用支持 FTPS 的客户端(如 FileZilla)连接到你的服务器。在连接设置中,选择 FTPS 并输入服务器地址、用户名和密码。
通过以上步骤,你应该能够在 Debian 上成功集成并运行一个 FTPS 服务器。