This question already has an answer here:
(This seems like an obvious / common question, but I couldn't find it when searching - maybe I wasn't using the correct terminology...)
I want to login over ssh to a remote machine, tar a directory, and download it to my local machine. I don't need to leave a copy on the remote server. Currently I ssh in, create the tar archive, logout, scp the file to my machine, the ssh back in to remove the archive. Not exactly efficient...
I know this doesn't work, but I'm thinking something like:
scp user@remote:"tar czf - /my/directory/" ./my/local/destination/archive.tgz
Or is there a better way?