Prefered method if ssh is available.
Another way, if you have SSH:
rsync -aE -e ssh directory user@hostB:target_dir
or from hostB
rsync -aE -e ssh user@hostA:directory target_dir
You can also use the z (--compress) switch to rsync if network throughput is an issue.