GNU Privacy Guard: Difference between revisions

From Leo's Notes
This page was last edited on 25 June 2013, at 07:13.
Line 6: Line 6:
== Automating Encrypted Backups using Asymmetric Keys ==
== Automating Encrypted Backups using Asymmetric Keys ==


#!/bin/sh
HOSTNAME=`hostname`
DATE=`date +%Y-%m-%d`
  # Get the public key to encrypt with
  # Get the public key to encrypt with
  wget -O - http://leo.home.steamr.com/public/backup_key.pub | gpg --import
  wget -O - http://leo.home.steamr.com/public/backup_key.pub | gpg --import
   
   
  # generate the backup
  # Create archive, pipe to gpg to encrypt, then send to freebsd
  tar -czp \
  tar -czpf - \
        /usr/share/sickbeard/ \
        /etc/init.d/sickbeard  \
        \
        /usr/share/SABnzbd/ \
        /etc/init.d/SABnzbd  \
        \
        /home/rt \
        /var/www/html/rutorrent \
        /usr/lib64/httpd/modules/mod_scgi.so \
        /etc/httpd/conf.d \
        /etc/httpd/conf/httpd.conf \
        \
         /etc/fstab \
         /etc/fstab \
         /etc/passwd \
         /etc/passwd \
         /etc/group \
         /etc/group \
         /etc/shadow \
         /etc/shadow \
  | gpg --encrypt --yes --no-tty --trust-model always --output `hostname`-`date +%Y-%m-%d`.tar.gz.gpg --recipient leo@steamr.com
  | gpg --encrypt --yes --no-tty --trust-model always --recipient leo@steamr.com \
| ssh backup@freebsd "cd /storage/backups/archived/sickbeard; cat - > $HOSTNAME.$DATE.tar.gz.gpg"
   
   
  # delete the public backup key
  # delete the public backup key

Revision as of 07:13, 25 June 2013

GnuPG, also known as gpg is a program that lets you encrypt/decrypt data.

Exporting Public Key

gpg --armor --export leo@steamr.com --output leo.steamr.pub

Automating Encrypted Backups using Asymmetric Keys

#!/bin/sh

HOSTNAME=`hostname`
DATE=`date +%Y-%m-%d`

# Get the public key to encrypt with
wget -O - http://leo.home.steamr.com/public/backup_key.pub | gpg --import

# Create archive, pipe to gpg to encrypt, then send to freebsd
tar -czpf - \
        /usr/share/sickbeard/ \
        /etc/init.d/sickbeard  \
        \
        /usr/share/SABnzbd/ \
        /etc/init.d/SABnzbd  \
        \
        /home/rt \
        /var/www/html/rutorrent \
        /usr/lib64/httpd/modules/mod_scgi.so \
        /etc/httpd/conf.d \
        /etc/httpd/conf/httpd.conf \
        \
        /etc/fstab \
        /etc/passwd \
        /etc/group \
        /etc/shadow \
| gpg --encrypt --yes --no-tty --trust-model always --recipient leo@steamr.com \
| ssh backup@freebsd "cd /storage/backups/archived/sickbeard; cat - > $HOSTNAME.$DATE.tar.gz.gpg"

# delete the public backup key
gpg --batch --yes --delete-key leo@steamr.com