Skip to content

Use GPG to decrypt a file using our best settings

Notifications You must be signed in to change notification settings

SixArm/gpg-decrypt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gpg-decrypt:
decrypt a file using our best settings

GnuPG

Syntax:

gpg-decrypt <file>

Example:

$ gpg-decrypt example.txt.gpg > example.txt

Output is a new decrypted file:

example.txt

Settings

To get our settings, we use these gpg options:

  • --quiet: Try to be as quiet as possible.
  • --no-greeting: Suppress the initial copyright message but do not enter batch mode.

If you are on an older system, then you may want to add this:

  • --no-use-agent: Do not use a system agent such as Ubuntu's gnome-keyring process.

  • --pinentry-mode=loopback: Use the terminal for PIN encry.

More examples

To decrypt a file:

$ gpg-decrypt foo.gpg

To decrypt a file to a specific output file name:

$ gpg-decrypt foo.gpg --output goo

To decrypt a directory:

$ gpg-dncrypt foo.tar.gpg | tar -x

To decrypt a file then delete it:

$ gpg-decrypt foo.gpg && rm foo.gpg

To decrypt a directory then delete it:

$ gpg-dncrypt foo.tar.gpg | tar -x && rm foo.tar.gpg

Advice

We tend to use these naming conventions:

  • GPG file name extension .gpg.
  • tar file extension .tar.

We tend to skip compression:

  • We tend to use gpg without using compression.
  • We tend to use tar without using compression.

Command

The command is:

gpg \
--decrypt \
--quiet \
--no-greeting \
--pinentry-mode=loopback \
"$@"

Troubleshooting

TTY

If you get error messages like this:

gpg: Inappropriate ioctl for device
gpg: problem with the agent: Inappropriate ioctl for device
gpg: error creating passphrase: Operation cancelled
gpg: symmetric encryption of `[stdin]' failed: Operation cancelled

Then try this:

$ export GPG_TTY=$(tty)

Restart

If you get error message like this:

gpg: WARNING: server 'gpg-agent' is older than us (2.2.6 < 2.2.7)
gpg: Note: Outdated servers may lack important security fixes.
gpg: Note: Use the command "gpgconf --kill all" to restart them.
gpg: signal Interrupt caught ... exiting

Then try this:

$ gpgconf --kill all

See also

These commands are similar:

  • gpg-encrypt: use GPG to encrypt a file using our best settings.

  • gpg-decrypt: use GPG to decrypt a file using our best settings.

  • openssl-encrypt: use OpenSLL to encrypt a file using our best settings.

  • openssl-decrypt: use OpenSSL to decrypt a file using our best settings.

Tracking

About

Use GPG to decrypt a file using our best settings

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages