2

My OS is Ubuntu 20.04.2 lts.

I am creating a tar archive from the dir noup1, that contains files and subfolders, with tar cf no1.tar noup1

Encrypt it with gpg -c no1.tar. So now I have a no1.tar.gpg archive.

If I try to decrypt it with gpg -d no1.tar.gpg, I get a lot of squiggly characters in the terminal and it does not work.

If I just use gpg no1.tar.gpg, without the -d flag, I get an output saying "no command was given. Trying to guess ..."

gpg: WARNING: Kein Kommando angegeben. Versuche zu raten was gemeint ist ... gpg: AES256 verschlüsselte Daten gpg: Verschlüsselt mit einer Passphrase

and the archive is now unencrypted. So this works! But how and why?

On the other hand if I use the -d flag and pipe the result into tar it succeeds!

gpg -d no1.tar.gpg | tar xf -

How to create compressed encrypted archives with tar and gpg

So I am wondering:

What is the "guessed command" that was executed?

Why does the -d flag not work, but it does if piped into tar, even though all relevant tutorials instruct to decrypt a tar archive using gpg -d <archive-name> and not gpg <archive-name>?

Is it possible I am missing some packages or something is wrong with my gpg configuration?

1 Answer 1

0

per the manpages for gpg,

-d

Decrypt the file given on the command line (or STDIN if no file is specified) and write it to STDOUT (or the file specified with --output). If the decrypted file is signed, the signature is also verified. This command differs from the default operation, as it never writes to the filename which is included in the file and it rejects files which don't begin with an encrypted message.

so -d was working fine, but it was decrypting the file to the STDOUT, which is why you saw a bunch of junk output. that is the encoded data for your .tar file, so its no surprise its gibberish.

if you want it to decrypt to a file instead of your shell output stream, use --output <filename> or redirect output to a file.

I believe (I can't read German) that when you ran the command on the file, I assume it ran the equivalent of

gpg -d no1.tar.gpg --output no1.tar

2
  • gpg -d no1.tar.gpg --output no1.tar has the following output on my system: gpg: Note: '--output' is not considered an option usage: gpg [options] --decrypt [filename] Commented Mar 15, 2021 at 13:55
  • 1
    Options have to be listed before commands: gpg --output no1.tar -d no1.tar.gpg Commented Apr 20, 2021 at 1:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .