ssh - transfers with gateway hopping

Hi,

I am having trouble transferring files from a source UNIX machine to a
destination UNIX machine by hopping via 2 gateway machines.
The user used for the transfer has been setup/authorized so no password is
required to login. Summerized:
source to gateway1 to gateway2 to destination

This is the command executed from the source computer:
tar cf - .|ssh gateway1 ssh gateway2 "ssh dest 'cd /tmp;tar xf -'"
I get following error:
tar: blocksize = 0

If I change the command to:
tar cf - .|ssh gateway1 ssh gateway2 "ssh dest tar xf -"

Then the files are transferred albeit into the wrong directory but the
command on the source computer never completes.

How can I fix:
1) get the cd /tmp to work
2) get the command to come back when the transfer is complete

Thanks for any help

Can you please explain your scenario?
Are you able to connect to destination system?

I don't think these gateway's should matter.

  • nilesh

I think you need to run the commands at the destination in a sub-shell at the destination (replace the single quotes with parenthesis)

tar cf - .|ssh gateway1 ssh gateway2 "ssh dest (cd /tmp;tar xf -)" 

may do what you require, but I don't have four machines to test this with, have tried it between two and it works.

And the reason the originating tar doesn't complete is probably because it is waiting for input from the command line (tar cf -) for the files you wish to archive. to close it you need a CTRL-D in the input stream, or give it a list, or a toplevel directory (tar cf - /top/level/directory/)