Reputation: 23
I'd like to extract and uncompress (tar/bzip2) a compressed directory on a remote machine and save the directory and all its contents to my local computer without having to connect back into my local machine from the remote one. How can I do this over SSH? The tar file doesn't need to be stored on the remote machine, only on the local machine. I have tried:
ssh remotehost.somewhere.com "tar xf mydirectory.tar.bz2 | bzip2 -c " > mylocaldirectory
Upvotes: 2
Views: 2558
Reputation: 5617
What flows through pipe is but a stream of bytes, so you don't "pipe" a directory.
I suppose the archive exists on remote machine. This command extract a remote archive to local directory:
ssh HOST "cat mydirectory.tar.bz2" | tar xj -C mylocaldirectory
Upvotes: 3