I have a huge directory I want to copy to another machine as a .tar.gz file. I don't have a lot of space on either machine, so I'd like to copy the file through a pipe, like this:

tar -czf - mydirectory | ssh other.machine.science "cat > file/location/myfile.tar.gz"

The computer I'm logging in to has my shell set to nologin, though, as I am only allowed to copy files on and off of it with scp.

How can I copy a file from a pipe to a system where I don't have shell access?


You could just use scp -r to copy your local directory recursively. This will use more space on the remote end than a compressed tar file, but there seems to be little point in copying such a file without the ability to extract it.

scp -r mydirectory other.machine.science:/path/to/newdirectory
  • The machine is literally a tape archive, and copying a large number of files to it is a bad idea. – Dan Nov 22 '16 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.