‘tar’ is a good tool for moving files because it retains symbolic links and user/group permissions properly. A simple ‘Tar Pipe’ can be done to send and get files:
To send:
tar cf – myfiles | ssh remotehost ” ( cd /destination/path ; tar xf – ) ”
To get:
ssh remotehost “( cd /source/path; tar cf – desiredfiles ) ” | tar xf –
Multiple ssh connections can be strung together to move the file across multiple machines. For that, send through:
tar cf – myfiles | ssh remotehost1 ” ssh remotehost2 ” ( cd /destination/path ; tar xf – ) ” ”
To get through:
ssh remotehost1 ” ssh remotehost2 “( cd /source/path; tar cf – desiredfiles ) ” ” | tar xf –
Note that ‘tar cf’ and ‘tar xf’ can be replaced with ‘tar czf’ and ‘tar xzf’ for gzip compression. Or, for bzip2 compression: ‘tar ‘cjf’ and ‘tar xjf’.
Use ssh-agent and the ‘ssh -A’ (ForwardAgent) switch to remove the need to type passwords repeatedly.