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...

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState