Ubuntu 下 SSH 传输慢,通常和网络、SSH 配置、加密算法、DNS有关。下面按“最常见 → 进阶”给你一套排查和优化方案,基本能解决 90% 的情况。
time scp file user@host:/tmp/
或
ssh user@host "echo ok"
服务端 /etc/ssh/sshd_config:
UseDNS no
GSSAPIAuthentication no
然后:
sudo systemctl restart ssh
客户端也可加:
GSSAPIAuthentication no
ssh user@192.168.1.10
避免 DNS 解析卡顿。
默认 aes-256-gcm 不一定最快。
测试:
scp -c aes128-gcm@openssh.com file user@host:/tmp/
或服务器端:
Ciphers aes128-gcm@openssh.com,chacha20-poly1305@openssh.com
客户端 ~/.ssh/config:
Host *
Compression no
TCPKeepAlive yes
如果是高延迟网络:
Host *
IPQoS throughput
如果你只是传文件:
rsync -avP file user@host:/path/
tar czf - dir | ssh user@host "cd /tmp && tar xzf -"
ip link show
尝试:
sudo ifconfig eth0 mtu 1400
ping host
mtr host
sftp 也慢 → 直接 nc# 接收端
nc -l 1234 > file
# 发送端
nc host 1234 < file
✅ UseDNS no
✅ GSSAPIAuthentication no
✅ 用 rsync
✅ 换 aes128-gcm
✅ 用 IP 不用域名
如果你愿意,可以告诉我:
我可以直接给你一套最优配置。