How to copy a tar file on a series of remote hosts and untar it on those hosts?

Am trying to copy a tar file onto a series of remote hosts and untar it at the destination. Need to do this without having to do multiple ssh.
Actions to perform within a single ssh session via shell script

  • copy a file
  • untar at destination (remote host)

OS : Linux RHEL6

Please describe your operating system in details.

We cannot read minds and most of us here do not have superpowers to see into computer systems using our imagination.

Hello sankasu,

I have a few to questions pose in response first. I'm sure with over 50 posts, you will know what we need:-

  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)

Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.

We're all here to learn and getting the relevant information will help us all.

Kind regards,
Robin

Most cool: copy it via the stdin stream!

ssh remotehost "cd /destination && tar xvf -" < file.tar

The ssh is locally fed from the file.tar, and on the remote side the tar sucks from it.

2 Likes