Compress and transfer at the same time using SSH

Use the following command we will pipe the output of tar directly into ssh

tar zcvf - source-directory-name | ssh user@server "cat > /remote/directory/archive-name.tar.gz"

Where, zcvf stands for

  • -z : Compress archive using gzip program in Linux or Unix
  • -c : Create archive on Linux
  • -v : Verbose i.e display progress while creating archive
  • -f : Archive File name

You can extract the archive on the remote server using the following command:-

tar -xvf archive-name.tar.gz

This post gives explanation:-https://unix.stackexchange.com/questions/70581/scp-and-compress-at-the-same-time-no-intermediate-save

1 thought on “Compress and transfer at the same time using SSH”

  1. Pingback: Compress and transfer files to remote server using SCP command – linuxguides.net

Leave a Comment

Your email address will not be published. Required fields are marked *