Debian SFTP传输速度慢的排查与优化
一 快速定位瓶颈
iperf3 -s,客户端执行 iperf3 -c 服务器IP -P 4,观察带宽上限与抖动/丢包。若带宽远低于预期,优先排查网络质量与链路拥塞。top/htop、vmstat 1、iostat -dx 1 检查CPU、内存、磁盘I/O是否成为瓶颈(磁盘await、svctm高说明存储慢)。iftop、nethogs 确认是否有其他大流量占用带宽或连接数异常。/var/log/auth.log 是否有频繁认证失败、连接中断等异常。二 服务端 SSH 与 SFTP 配置优化
sudo apt update && sudo apt upgrade openssh-server openssh-client/etc/ssh/sshd_config 中设置:PubkeyAuthentication yesPasswordAuthentication nosudo systemctl restart sshMaxSessions、MaxStartups,避免连接排队与拒绝:MaxSessions 100MaxStartups 100:30:200Compression yesAllowTcpForwarding noX11Forwarding noSubsystem sftp internal-sftp三 系统资源与内核网络调优
/etc/security/limits.conf 增加(示例对用户 sftp_user):sftp_user soft nofile 65535sftp_user hard nofile 65535/etc/sysctl.conf 增加:fs.file-max = 65536sudo sysctl -pnet.ipv4.tcp_tw_reuse = 1net.core.rmem = 4096 87380 16777216net.core.wmem = 4096 65536 16777216sudo sysctl -pnoatime 挂载选项以减少元数据写入。四 客户端与传输策略优化
tar -czvf archive.tar.gz 小文件目录,再传输,显著降低元数据/握手开销。五 安全加固与维护建议
sudo apt install fail2bansudo systemctl enable --now fail2ban/var/log/auth.log 与系统资源,定期更新系统与 OpenSSH。