I have two server (LOCAL) and (REMOTE)

I want to untar a file from LOCAL ( on REMOTE ( via an SSH connection. What command can I use for that?

source path: /home/user/example.tar.gz

target path: /mnt/untar/extracted_folder


On the source system (LOCAL):

ssh -e none 'tar -xzf - -C /mnt/untar/' </home/user/example.tar.gz
  • bash: /home/user/example.tar.gz: No such file or directory i m getting this error – Amrut Nadgiri Aug 23 '17 at 7:34
  • 2
    @AmrutNadgiri And what shall I do about it if you say the file is there but it isn't? – Hauke Laging Aug 23 '17 at 8:37

Try this

ssh root@host1 "cd /dir/tocopy/ && tar -cf - ." | \
ssh root@host2 "cd /dir/tocopyto/ && tar -xf -"


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.