Short form:
You can limit the bandwidth the scp
uses with the -l
switch, you pass a number that's in kbits/sec.
I'd rather set this in my .ssh/config
file for certain names machines.
What's the equivalent named setting for -l
? I haven't been able to find it.
Followup question:
Generally, not sure how to map back and forth between ssh command line options and config names, short of doing Google searches or manually comparing man pages on a case by case basis. Is there a table that directly equates the two?
Longer form of first question, with context:
I've started using ssh config quite a bit, especially now that I need to go through a proxy and do lots of port mappings. I even define the same machine more than once depending on what type of tunneling I need.
However, when uploading a large file, it's difficult to do anything else on my machine. Even though I have more download bandwidth than up, I think that scp
saturates the link so even my small requests can't reach the Internet.
There's a fix for this, using the -l
bandwidth command line switch for scp
.
scp -l 1000 bigfile.zip titan:
I'd like to use this in my config instead, so I'd create an additional named entry called "titan-upload" and I'd use that as the target whenever I upload.
So instead of:
scp bigfile.zip titan:
I'd say:
scp bigfile.zip titan-upload:
Or even set different caps depending on where I am:
scp bigfile.zip titan-upload-from-work:
vs.
scp bigfile.zip titan-upload-from-home:
I'm generally on Mac and Linux.
Best Answer
Alas, as was mentioned, there doesn't see to be a config option to limit bandwidth. (I checked source code!)
Some possible solutions are to use an alias for scp, or perhaps a function. Bash is typically the default shell on both mac & linux, so this could work:
(note trailing space inside quotes!1) This would cause EVERY scp command you use to throttle bandwidth. Considering your situation, perhaps the best solution overall.
The second might be a good choice, since you could use scp for 'normal' transfers, and scp-throttle for slower transfers.
Or a function, with a bit more brains:
Basically, if we find '-upload' anywhere in the arguments, we perform the transfer with the bw limit, otherwise, a normal transfer occurs.
This would allow you to continue using your multiple names/aliases to denote actions.
scp aaa titan:
- would upload normallyscp aaa titan-upload:
- would throttlescp titan:aaa .
- normalscp titan-upload-from-home:aaa .
- throttledscp a-file-to-upload titan:
- oops, throttled, not intentional!EDIT:
1 - The trailing space INSIDE the alias allows further alias expansion after the aliased command. VERY helpful/useful.
Bash Man Page, __ALIASES__ section