Vamsi Pavan’s Place

When curiousity outbursts …..

Copying Files

August 5th, 2005 · No Comments · Linux

‘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.

Bookmark it! These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • StumbleUpon
  • BlinkList
  • YahooMyWeb
  • NewsVine
  • blogtercimlap
  • Netvouz
  • Technorati
  • Slashdot
  • Print this article!

Tags:

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment