Create a password-protected archive of a directory on a remote machine

2

Here is what I would like to achieve: There is a rather large (~15TB) directory on a local machine that I would like to archive on a remote machine.

These are the prerequisites I thought of

  1. impossible to use temporary local files due to storage limitations on the local machine
  2. the data should arrive as an archived stream (e.g. tar) so that the small files in the sub-directories do not bog down the file system on the remote machine
  3. file transfer should be encrypted
  4. the archive on the remote machine must be password protected to prevent people from spying on my data
  5. the connection is fast enough, so compression is not necessary

I tried lots of combinations with tar, gpg and ssh but fail at piping them together correctly.

MechEng

Posted 2017-07-24T08:11:59.350

Reputation: 21

So how did those tries look and what failed about them? – Seth – 2017-07-24T09:40:39.793

Showing some of my failed attempts would demonstrate two things: 1: I know very little about what I am trying to do; 2: I tried long enough to find an answer on my own to earn the right to ask for help. It would not make things any clearer to add my failed attempts. – MechEng – 2017-07-24T09:49:21.637

With the difference that you would learn something in the process because people would be able to point out what errors are responsible for it not to work. If you're looking for a ready to go software you should check out the Software Recommendations Exchange. If you expect someone to do your work for you, you might want to pay him. Aside from that, you're probably on the right track by using ssh and tar. Though it doesn't support password protection/encryption. You'd have to do stream encryption with this setup. Again GPG might fit that bill.

– Seth – 2017-07-24T09:54:21.100

Answers

-1

Use this command on your source machine

tar cf - /path/to/your/dir | gpg -o - --symmetric - | ssh user@remotehost "cat - > /path/to/destination/file.tar.gpg"
  1. tar cf - /path/to/your/dir is creating your archive but sends it to standard output
  2. gpg -o - --symmetric - is encrypting the tar file received on standard input thanks to the pipe (this is done with the last - of the command) and outputs the results to standard output (done with -o -)
  3. ssh user@remotehost "cat - > /path/to/destination/file.tar.gpg" using ssh to transport the standard output of the previous command as the standard input for the cat command which finally redirects to a file on the remote machine

Julie Bouillon

Posted 2017-07-24T08:11:59.350

Reputation: 1