How to pipe scp/ssh file transfer(pull) through tar (remote->local transfer initiated from local machine)
try from user@localhost
> ssh -l remoteuser remotehost "tar cf - dir_to_transfert" > remote.tar
where
>
is the promptssh -l remoteuser remotehost
connect you to remote host"tar cf - dir_to_transfert"
perform remote tarin to standard output> remote.tar
redirect ssh's output to localfile name remote.tar
this will work if you are allowed tar on remote host.
Related videos on Youtube
Nandita Dey
Updated on September 18, 2022Comments
-
Nandita Dey over 1 year
I would like to pipe an scp pull operation(sample without tar below) through tar, so that only one tar file is written for about 10 directories:
user@localhost:/home/user> scp -r remoteuser@remotehost:dir_to_transfer ./
I have directories on a remote machine that have about 10,000 small(~28k)files per directory to transfer. Due to file quotas, I don't have much free space to run the tar command on the remote host(remotehost). Due to firewall rules, I can only initiate the transfer from my local machine(localhost).
The sheer number of files makes the transfer very long.
I have found examples of how to do this when "pushing" the data, but would like to know how to do this when "pulling" the data.
Local machine info:
OS:OpenSuSe 13.2(x86_64)
bash 4.2.53(1)
OpenSSH_6.6.1p1, OpenSSL 1.0.1k-fips 8 Jan 2015
Remote machine info:
- OS: CentOS release 5.11 (Final)
- bash 3.2.25(1)
- OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
-
Barmar about 9 yearsYou have an extraneous
)
character -
Арсений Черенков about 9 years@Barmar thank, my first intend was
( ssh ... ) > foo
, but since local shell get>
first. -
Barmar about 9 yearsYeah,I had a feeling it was an edit like that