在Debian上實現FTP over TLS(FTPS)使用vsftpd(Very Secure FTP Daemon)需要幾個步驟。以下是詳細的指南:
首先,確保你的系統是最新的,然后安裝vsftpd。
sudo apt update
sudo apt install vsftpd
編輯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
# 允許匿名用戶登錄(如果需要)
anonymous_enable=NO
# 允許本地用戶登錄
local_enable=YES
# 允許寫操作
write_enable=YES
# 其他安全設置
chroot_local_user=YES
allow_writeable_chroot=YES
# 日志記錄
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=NO
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=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(Uncomplicated Firewall),可以這樣配置:
sudo ufw allow 21/tcp
sudo ufw allow 990/tcp # FTPS數據連接端口
sudo ufw enable
你可以使用FTP客戶端(如FileZilla)來測試FTPS連接。在FileZilla中,選擇“FTPES - Explicit TLS”作為協議,并輸入你的服務器地址、用戶名和密碼。
在FileZilla中,連接到服務器后,檢查連接是否通過SSL/TLS加密。你可以在“傳輸設置”中查看SSL/TLS狀態。
通過以上步驟,你應該能夠在Debian上成功配置并運行FTPS服務。