在Debian FTP服务器上使用FTP over TLS(FTPS)可以提供更安全的文件传输。以下是设置FTPS的步骤:
首先,确保你的Debian系统是最新的,并安装vsftpd
和openssl
。
sudo apt update
sudo apt install vsftpd openssl
编辑vsftpd
的配置文件/etc/vsftpd.conf
。
sudo nano /etc/vsftpd.conf
在文件中添加或修改以下配置项:
# 启用SSL/TLS
ssl_enable=YES
# 强制使用SSL/TLS
force_local_data_ssl=YES
force_local_logins_ssl=YES
# 使用SSL/TLS证书和密钥
rsa_cert_file=/etc/ssl/private/vsftpd.pem
rsa_private_key_file=/etc/ssl/private/vsftpd.pem
# 允许匿名用户使用SSL/TLS
allow_anon_ssl=NO
# 允许本地用户使用SSL/TLS
local_enable=YES
# 允许写操作
write_enable=YES
# 启用被动模式
pasv_enable=YES
pasv_min_port=50000
pasv_max_port=50100
# 其他安全设置
chroot_local_user=YES
allow_writeable_chroot=YES
如果你还没有SSL/TLS证书和密钥,可以使用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流量。如果你使用的是ufw
,可以添加以下规则:
sudo ufw allow 21/tcp
sudo ufw allow 50000:50100/tcp
sudo ufw reload
你可以使用FTP客户端(如FileZilla)来测试FTPS连接。在FileZilla中,选择FTP over TLS(显式)模式,并输入你的服务器地址、用户名和密码进行连接。
600
。通过以上步骤,你应该能够在Debian FTP服务器上成功设置和使用FTP over TLS。