Philip Philip - 3 months ago 8x
Linux Question

How to copy multiple flies simultaneously using scp

I would like to copy multiple files simultaneously to speed up my process I currently used the follow

scp -r .

but it only copies one file at a time. I have a 100 Mbps fibre so I have the bandwidth available to really copy a lot at the same time, please help.


SSH is able to do so-called "multiplexing" - more connections over one (to one server). It can be one way to afford what you want. Look up keywords like "ControlMaster"

Second way is using more connections, then send every job at background:

for file in file1 file2 file3 ; do 
     scp $file server:/tmp/ & 

But, this is answer to your question - "How to copy multiple files simultaneously". For speed up, you can use weaker encryption (rc4 etc) and also don't forget, that the bottleneck can be your hard drive - because SCP don't implicitly limit transfer speed.

Last thing is using rsync - in some cases, it can be lot faster than scp...