在 Linux 下使用 SFTP 传输慢,通常和网络、加密算法、并发、磁盘 IO、配置参数有关。下面按「最有效 → 可选优化」给你一套实用提速方案。
ping 目标IP
iperf3 -c 目标IP
sftp 的批量模式(避免一次次握手)❌ 慢:
sftp user@host
put a.txt
put b.txt
✅ 快:
sftp user@host <<EOF
put *.log
EOF
或一次传目录:
sftp -r user@host:/remote/path /local/path
SFTP 基于 SSH,加密很吃 CPU。
ssh -Q cipher
sftp -c aes128-gcm@openssh.com user@host
或
sftp -c chacha20-poly1305@openssh.com user@host
老机器用
aes128-ctr也很稳
服务端 /etc/ssh/sshd_config:
UseDNS no
然后:
systemctl restart sshd
/etc/ssh/sshd_config:
UseDNS no
GSSAPIAuthentication no
MaxSessions 50
sysctl -w net.ipv4.tcp_window_scaling=1
sysctl -w net.core.rmem_max=16777216
sysctl -w net.core.wmem_max=16777216
永久生效:
/etc/sysctl.conf
❌ 慢:
sftp put dir/*
✅ 快:
tar czf dir.tgz dir/
sftp put dir.tgz
rsync -avzP file user@host:/path/
优点:
lftp sftp://user@host
set net:max-rate 0
set net:connection-limit 10
mirror -P 10 /remote /local
最推荐:
rsync -avzP --rsh="ssh -c aes128-gcm@openssh.com" dir/ user@host:/path/
如果你愿意,可以告诉我:
我可以给你一套针对性配置。