如何在Ubuntu FTP Server上高效傳輸大文件
Ubuntu上常用的FTP服務器軟件中,vsftpd(Very Secure FTP Daemon)因其安全性高、性能穩定,是大文件傳輸的首選。ProFTPD也可作為替代方案,但配置復雜度略高。
通過終端執行以下命令安裝最新版本:
sudo apt update && sudo apt install vsftpd
編輯vsftpd的主配置文件/etc/vsftpd.conf(使用sudo nano /etc/vsftpd.conf),修改以下核心參數以支持大文件傳輸:
pasv_enable=YES)允許客戶端打開端口供服務器連接,更適合防火墻后的環境。pasv_enable=YES
pasv_min_port=1024 # 起始端口(建議≥1024)
pasv_max_port=1048 # 結束端口(根據需求調整)
ftpd_send_cmd=STOR
ftpd_recv_cmd=RETR
# local_max_rate=0 # 0表示無限制(單位:字節/秒)
# anon_max_rate=0
large_file_support=YES
chroot_local_user=YES),防止越權訪問:chroot_local_user=YES
allow_writeable_chroot=YES # 允許用戶寫入主目錄
修改完成后,重啟vsftpd服務使配置生效:
sudo systemctl restart vsftpd
Ubuntu默認使用ufw防火墻,需開放FTP控制端口(21)和被動模式端口范圍:
# 允許FTP控制端口(21)
sudo ufw allow 21/tcp
# 允許被動模式端口范圍(示例:1024-1048)
sudo ufw allow 1024:1048/tcp
# 重新加載防火墻規則
sudo ufw reload
推薦使用FileZilla(跨平臺、易操作),配置步驟如下:
sudo apt install openssh-server
客戶端使用SFTP協議連接(端口22)。sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.key -out /etc/ssl/private/vsftpd.crt
在vsftpd.conf中添加:ssl_enable=YES
rsa_cert_file=/etc/ssl/private/vsftpd.crt
rsa_private_key_file=/etc/ssl/private/vsftpd.key
force_local_data_ssl=YES
force_local_logins_ssl=YES
netstat命令查看FTP連接狀態:sudo netstat -tuln | grep vsftpd
/var/log/vsftpd.log):sudo tail -f /var/log/vsftpd.log
chmod 755 /home/username)。通過以上步驟,Ubuntu FTP Server可穩定支持大文件傳輸。根據實際需求選擇合適的優化措施,能進一步提升傳輸效率和安全性。