1、scp限速
scp -l 800 a.txt user@ip:/home/admin/downloads
此時的傳輸速率就是800/8=100KB左右
man -a scp查看參數含義。注意單位是bit

2、rsync是用來同步更新的,也可以用來上傳文件,但是不建議這樣使用
man -a rsync查看參數幫助信息
使用rsync實現限速100KB/s
rsync -auvzP --bwlimit=100 本地文件 遠程文件
參數說明:
v:詳細提示
a:以archive模式操作,復制目錄、符號連接,等價於 -rlptgoD 。
z:壓縮
u:只進行更新,防止本地新文件被重寫,注意兩者機器的時鍾的同時
P:是綜合了--partial --progress兩個參數,
此時的rsync支持了斷點續傳
3、paramiko限速使用的是http://docs.paramiko.org/en/latest/api/sftp.html里的
classmethod
from_transport
(t, window_size=None, max_packet_size=None)。官方發文稱:
etting the window and packet sizes might affect the transfer speed. The default settings in the
Transport
class are the same as in OpenSSH and should work adequately for both files transfers and interactive sessions.
只是可能起到限速的左右,而且正確用法是:
window_size有個最大值和最小值、默認值,你必須選擇其間的值。
默認值是64*2**15字節,也就是2M。最小值是32K,最大值是2的32次方減去1。
但是測試的時候發現,限速其實沒有起作用

測試代碼:
4、但是網上倒是給了個加速上傳和下載的方法:http://1codelife.com/2017/11/30/paramiko-larger-file-update/