Reputation: 450
Objective: I am trying to copy a folder and its files from HOST_C to HOST_A. ssh
or scp
can only be done through HOSTB due to keys.
Infrastructure:
HOST_A<-->HOST_B<-->HOST_C
Current procedure:
ssh to host_B
scp -r from folder at C to folder on B
exit ssh from B
scp -r from folder on B to folder on A
ssh to host_B again
rm -r folders created
I have made some attempts using ProxyCommand but without luck.
Any suggestions are welcome
Upvotes: 1
Views: 587
Reputation: 3247
You could connect from host B to host C with ssh, create a tar archive of the folder to copy and send the output to STDOUT and pipe all this to a second ssh session which connects to host A and unpacks the tar archive received on STDIN.
ssh host_C "cd /somewhere; tar czpf - folder" | ssh host_A "cd /somewhere; tar xzpf -"
Upvotes: 1