copying files between 2 remote hosts

I was in this position where my host has access to access to host A and host B but host A cannot access host B

I need to copy data between A and B, the first thing i tried was to copy from A to myhost and from myhost to B

stupid! time wasting! yes...

Then with Eero heino my colleague we did this

ssh A "tar cf - /path/to//file"|ssh B "tar xf - -C /path/to/dest/"

It works!