Dual ssh
Even in a difficult case, you can handle file transfers using a single command line, just using ssh ;-)
And this is useful if remote1 cannot connect to localhost :
ssh user1@remote1 'ssh user2@remote2 "cat file"' > file
tar
But you lose the properties of the file (ownership, permissions ...).
However, tar is your friend to save these file properties:
ssh user1@remote1 'ssh user2@remote2 "cd path2; tar c file"' | tar x
You can also compress to reduce network bandwidth:
ssh user1@remote1 'ssh user2@remote2 "cd path2; tar cj file"' | tar xj
And tar also allows you to migrate a recursive directory through basic ssh :
ssh user1@remote1 'ssh user2@remote2 "cd path2; tar cj ."' | tar xj
ionice
If the file is huge and you do not want to disturb other important network applications, you can skip the network bandwidth limit provided by scp and rsync tools (for example, scp -l 1024 user@remote:file do not use more than 1 Mbps).
But a workaround is using ionice to save one command line:
ionice -c2 -n7 ssh u1@remote1 'ionice -c2 -n7 ssh u2@remote2 "cat file"' > file
Note: ionice may not be available on older distributions.
oliber 04 Feb '12 at 9:01 2012-02-04 09:01
source share