GnuPG Hacks

GnuPG does a lot more than just encrypt and decrypt e-mail and attachments.
Learning More

There are several good introductions to using the more common features of GnuPG, such as the GnuPG MiniHOWTO by Brenno de Winter at the GnuPG Web site (see Resources). They explain in detail how to use the more common public key cryptography features of GnuPG.

The GnuPG mailing lists are also very useful and fully archived on the GnuPG Web site. Werner Koch, the GnuPG lead developer, frequently posts to the mailing lists and is of invaluable help.

Resources for this article: /article/8743.

Tony Stieber is an information security professional specializing in UNIX systems, cryptology and physical security. He has been learning Linux since 1999, UNIX since 1987 and computers since before 1980. He does not yet know what the next decade will offer.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

wrong correction?

Anonymous's picture

> The stdin (file descriptor 0) of the gpg process is filename txt,
rather than passphrase.txt, so your (intended) passphrase is never actually used!

Then how come the decryption worked?

I like this article

felipe1982's picture

i've been using GPG for a few years, and never knew about the --enarmor option (it isn't even in man page for version 1.2.6. I also like the built-in RNG, which I never knew existed. I enjoyed this tutorial did not include information about public key crypto, which is much more common on the web. That makes this article (and ones like it) in shorter supply == more valuable.

Thanks!

GPG should not be used here

Anonymous's picture

GPG should not be used here at all. According to the man page, the input password is not even hashed.
Have a look at aesloop instead. (Or maybe openssl enc alternatively)

gpg --passphrase-fd 0 doesn't do what you think it does

Anonymous's picture

The following command, as given in the article, has a problem.

cat passphrase.txt | gpg --passphrase-fd 0 -c < filename.txt > filename.gpg

The stdin (file descriptor 0) of the gpg process is filename txt,
rather than passphrase.txt, so your (intended) passphrase is never actually used!

Use this instead:

gpg --passphrase-fd 3 -c 3<passphrase.txt < filename.txt > filename.gpg

You failed to spot the problem simply because the decryption command
has the same problem...

(The unescaped less-than character in my 2 previous posts seem to have caused problems.Please delete them/ignore them)

gpg --passphrase-fd 0 doesn't do what you think it does

Anonymous's picture

The following command, as given in the article, has a problem

cat passphrase.txt | gpg --passphrase-fd 0 -c < filename.txt > filename.gpg

The stdin (file descriptor 0) of the gpg process is filename txt,
and not passphrase.txt, so your (intended) passphrase is never actually used!

Use this instead:

gpg --passphrase-fd 3 -c 3 < passphrase.txt < filename.txt > filename.gpg

You failed to spot the problem simply because the decryption command
has the same problem...

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix