Skip to content

Instantly share code, notes, and snippets.

@tvvignesh tvvignesh/gpg.md
Last active Jul 19, 2018

Embed
What would you like to do?
Encrypt and Decrypt files using GPG Algorithm - https://www.gnupg.org/

Remove existing GPG Secret Keys

gpg --delete-secret-keys "Vignesh T.V."

Remove existing GPG Public Keys

gpg --delete-keys "Vignesh T.V."

Generate GPG Keys

gpg --gen-key

Export GPG Public Key

gpg --output ./mygpg.key --armor --export vigneshviswam@gmail.com

Export GPG Private Key

gpg --list-secret-keys (Get the ID from there and replace the ID below)

gpg --export-secret-keys 0009E10FB8CF0BD4699A72257250F6DB43FE74C2 > gpg-private.asc

Encrypt the file using GPG

gpg --trust-model always --encrypt --armor -o ./encrypted.asc -r vigneshviswam@gmail.com ./file.txt


Decryption

Import Private Key

gpg --import gpg-private.asc

Find GPGConf directories

gpgconf –list-dirs

Create GPGConf file in any of those directories with name gpg-agent.conf and with content

allow-loopback-pinentry

Reload GPG Agent

gpgconf --kill gpg-agent gpg-connect-agent reloadagent /bye

Create a .bat file with these contents (%1 is the command line argument to be passed from NiFi)

echo |gpg --pinentry-mode loopback --batch --passphrase-fd 0 -d %1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.