Results 1 to 6 of 6
Hello, I'm using CentOS 4.5 and I'm trying to find a script that will compress and / or encrypt files. I would like to use GPG but GPG does not ...
- 09-12-2007 #1Just Joined!
- Join Date
- Jul 2007
- Posts
- 21
GPG Script?
Hello, I'm using CentOS 4.5 and I'm trying to find a script that will compress and / or encrypt files. I would like to use GPG but GPG does not have the ability to recursively encrypt subdirectories; doing this manually will take too long to accomplish.
Ideally the script will take files in one or more directories including it's subdirectories, compress the files and then encrypt the files using GPG. Compressing is an option and not essential.
I tried to create a tar file then encrypt the file but ran out of disk space.
Thanks in advance,
- 09-12-2007 #2Just Joined!
- Join Date
- Sep 2004
- Posts
- 5
Try doing the compress as you tar eg
tar -czf file.tgz dir_to_be_processed/
optionally, you could do the tar first, then call gzip explicitly, using the option to do maximum compression, which may take a little while. See the man page.
After either of the above, try encryption.
- 09-12-2007 #3Just Joined!
- Join Date
- Jul 2007
- Posts
- 21
chrism01
Thats what I did first, I created the tar, compressing at the same time, before I encrypt the resulting file but ran out of disk space.
I wanted to see if there was a way to run the gpg encrypting automatically for all files without having to do do it manually.
Thanks
- 09-12-2007 #4This isn't clear to me.
Originally Posted by mjc
Given a directory /some-dir, which contains file1 and file2, what is the end result you're going for?
You want /some-dir tarred, compressed, and encrypted? The end result is one encrypted file.
Or you want file1 compressed and encrypted and then file2 compressed and encrypted? The end result is two encrypted files.
[ this doesn't speak to the space issue yet, but first I want to understand what you are doing. ]
- 09-12-2007 #5Just Joined!
- Join Date
- Jul 2007
- Posts
- 21
Hi,
Let me clarify, For example, please refer to the following:
Directory 1
-- subdirectory 1.1
----file a
----file b
----file c
------subdirectory 1.1.1
--------file a
--------file b
----------subdirectory 1.1.1.1
------------file a
------------file b
--subdirectory 1.2
----file a
----file b
Directory 2
-- subdirectory 2.1
----file a
----file b
----file c
----file d
--subdirectory 2.2
----file a
----file b
--subdirectory 2.3
----file a
----file b
----file c
----file d
In this example, I have two directories, each containing subdirectories with files. If I use GPG I have to encrypt each file separately, then tar and zip the entire directory tree. Encrypting each file will take too long to process; in actuality, I have close to a TB of data that needs to be processed; which is the basis for my question.
Hope this helps
- 09-12-2007 #6Not true. Back to my scenario for a moment:
Originally Posted by mjc
Use a statement like this:Code:[hector@troy ~]$ ls -l some-dir total 90 -rw------- 1 hector hector 0 Sep 12 12:07 file1 -rw------- 1 hector hector 90513 Jul 19 14:58 file2
Explanation:Code:[hector@troy ~]$ tar cfz - some-dir | gpg --encrypt --armor -r mykey > final.tar.gz.asc
- tar creates a gzipped archive of the some-dir directory and sends it to stdout.
- The pipe allows gpg to use tar's stdout as its stdin (presumably solving your disk space issue, since it does not get written to disk before being encrypted).
- gpg encrypts and ascii armors the archive using the 'mykey' gpg uid.
- The final result gets redirected to final.tar.gz.asc. It is a tarred, gzipped, encrypted, ascii armored archive.
In order to extract from that archive, you'll do the reverse.
1. Use gpg to decrypt the archive, and redirect that to a file. (You'll need an area large enough to do so.)
2. Un-tar/gunzip the archive.


Reply With Quote