如何在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可稳定支持大文件传输。根据实际需求选择合适的优化措施,能进一步提升传输效率和安全性。