Table of Contents
SSH - Tar
Preface
Some time you will need to copy a file between SSH Serer and SSH Client. It is possible to use standard “scp”. On another hand sometime it is handy to know as well about another possibilities. In this document I would like to describe the possibility to use SSH and TAR to compress the file at the same time as it will be transferred between SSH Client and SSH Server.
SSH Client ->copy-> SSH Server
Example
[user@SSH_Client ~]$ ls # We would like to copy this file source_file [user@SSH_Client ~]$ tar cvzf - source_file | ssh user@SSH_Server "cat> ~/destination_file.tar.gz" # Copy & Compress file source_file user@ssh_server's password: [user@SSH_Client ~]$ [user@SSH_Server ~]$ ls # We have created this file destination_file.tar.gz
In this way you can copy a file and compress it in same time. In the case that you would like to extract the data it is possible to use “ tar –vxzf destination_file.tar.gz “
SSH Server ->copy-> SSH Client
Example
[user@SSH_Server ~]$ ls # We would like to copy this file source_file [user@SSH_Client ~]$ ssh user@SSH_Server "tar cvzf - source_file " | cat> ~/destination_file.tar.gz # Copy & Compress file user@ssh_server's password: source_file [user@SSH_Client ~]$ [user@SSH_Client ~]$ ls # We have created this file destination_file.tar.gz
In this way you can copy a file and compress it in same time. In the case that you would like to extract the data it is possible to use “ tar –vxzf destination_file.tar.gz “