Skip to content

Instantly share code, notes, and snippets.

@brabect1
Last active August 14, 2022 12:57
Show Gist options
  • Select an option

  • Save brabect1/ae239b62eb85c3d8d857665d44e0a46a to your computer and use it in GitHub Desktop.

Select an option

Save brabect1/ae239b62eb85c3d8d857665d44e0a46a to your computer and use it in GitHub Desktop.
gpg usage for file encrypting and decrypting #gpg

Using GPG

# encrypt file
# (-armor will create an ASCII file)
gpg --encrypt --sign --armor -r <e-mail> <file>

# encrypt multiple files
for f in some/path/*.pdf; do g=${f##*/}; gpg --encrypt --recipient <e-mail> --armor --output $g.gpg $f; done

# decrypt
gpg --decryptd --output <file.dec> <file.enc>

# decrypt multiple files
for f in some/path/*.gpg; do g=${f##*/}; gpg --decrypt --output ${g%.*} ${f}; done

# export/backup keys
gpg --export-options backup  --export-secret-keys -o <file> <e-mail>

# import/restore keys
gpg --import-options restore --import <file>
@roy7414

roy7414 commented Aug 14, 2022

Copy link
Copy Markdown

thank you! this is very useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment