Linux security

How to encrypt and decrypt directory with gpgdir script

gpgdir is a perl script that uses the CPAN [easyazon_link asin=”1593270712″ locale=”US” new_window=”default” nofollow=”default” tag=”wn0d5-20″ add_to_cart=”default” cloaking=”default” localization=”default” popups=”default”] GnuPG [/easyazon_link]::Interface module to encrypt and decrypt directories using a gpg key specified in ~/.gpgdirrc.  This script will help you to encrypt and decrypt directories using  a GPG key. It supports recursively descending through a directory in order to make sure it [easyazon_link asin=”0470474246″ locale=”US” new_window=”default” nofollow=”default” tag=”wn0d5-20″ add_to_cart=”default” cloaking=”default” localization=”default” popups=”default”] encrypts [/easyazon_link]or decrypts every file in a target directory and all of its subdirectories.

Installation and configuration of gpgdir on Ubuntu:

  • Download the binary file, PGP key and verify signature
mkdir gpgdir
wget http://www.cipherdyne.org/gpgdir/download/gpgdir-1.9.5.tar.bz2
wget http://www.cipherdyne.org/gpgdir/download/gpgdir-1.9.5.tar.bz2.asc
wget http://www.cipherdyne.org/public_key
gpg --import public_key
gpg --verify gpgdir-1.9.5.tar.bz2.asc
  • Lets install the gpgdir script on Ubuntu box
tar xfj gpgdir-1.9.5.tar.bz2
cd gpgdir-1.9.5
./install.pl
  • We have to configure gpgdir for use with your default GPG key
vi /usr/local/src/gpgdir
  • Make a change in the conf file .. uncomment line “default_key and save
.
# Uncomment to use the GnuPG default key defined in ~/.gnupg/options:
default_key
# If you want to specify manually the right key enter it on next line
use_key 000BBD1XX
.

This complete the installation and configuration of gpgdir. You can now use it to encrypt or decrypt directories and you can do it manually or you can write simple bash script.

Man Page and usage of the gpgdir

Simply usage of Encrypt or Decrypt directory

gpgdir --encrypt {directory}
gpgdir --decrypt {directory}
## Encrypt directory and wipe out the original once encrypted
gpg -W -e {directory}

This could be integrated nicely into simple script.

[easyazon_block add_to_cart=”default” align=”left” asin=”0764541889″ cloaking=”default” layout=”left” localization=”default” locale=”US” nofollow=”default” new_window=”default” tag=”wn0d5-20″]

One Reply to “How to encrypt and decrypt directory with gpgdir script”

  1. Pingback: My Homepage

Leave a Reply