gpg snippets

Trusted and sensitive email protection with GPG using Gmail with Firefox

Tagged firefox, gmail, gpg, trusted emails, sensitive emails, firegpg  Languages bash

It's really simple to use GPG to encrypt and/or sign email you send through Gmail.

Generate your private key.

gpg --gen-key

Extract your public key, which you will send to people you need to communicate securely with.

gpg --armor --export [email protected] > my_public_pgp_key

Install FireGPG and restart the browser. Use GPG in Gmail.

How to encrypt/decrypt a file with GPG

Tagged decrypt, encrypt, gpg, password  Languages bash

First, install GPG:

brew install gpg

To encrypt a file with GPG, run:

gpg -c secrets.txt

To decrypt the encrypted and password-protected GPG file, run:

gpg secrets.txt.gpg

Simple backup script with GPG encryption

Tagged backup, gpg, tar  Languages bash

Save to a file named backup and run chmod +x backup:

#!/bin/bash
#
# Uses tar to store files in one TAR file.
# Uses gpg to encrypt the TAR file.
#
# Example:
#
# ./backup /folder-to-backup
#
#
export DIR_NAME=$1
export BACKUP_DATE=`date +"%Y%m%d-%H%M"`
export BACKUP_FILE=$DIR_NAME-$BACK_UPDATE.tar
tar -cvf $BACKUP_FILE $DIR_NAME
#
# TODO:
# --exclude="*.log"
# -r = recipient (only one who can decrypt)
#
gpg --encrypt -r [email protected] $BACKUP_FILE