This is the tar command to extract a compressed archive:

tar -xz -C <destination_folder> -f <tar_file>

If we want to download files from a remote server over SSH we can use tar to compress and archive on the fly like this:

local$ tar -xz -C ~/ -f <(ssh naveed@remote_ip "tar -zc -C ~/ <folder_to_download>")

To transfer files from local to remote computer ove SSH:

local$ tar -cz -C ~/ <folder_to_transfer> | ssh naveed@remote_ip "tar -zx -C ~/ ." `

Note: the <(cmd) construct is new to bash and doesn’t work on older systems. It runs a program and sends the output to a pipe, and substitutes that pipe into the command as if it was a file. -C flag is used to change the directory before the files are accessed by tar.