A site devoted to discussing techniques that promote quality and ethical practices in software development.

Wednesday, December 12, 2012

Using Gpg in Ubuntu 12.04 - replacement of GPA

Ever since I migrated from Ubuntu 11.04 upwards, I have lost the use of GPA and can only use it with super user privilege.

While that works very nicely it creates the ~/.gnupg directory with root ownership preventing other gnupg program, such as Seahorse, from accessing the keys. Seahorse does not even report access problem. It simply does not work well leaving the user oblivious of the underlying problem.

In the past, one can rely on the Encryption plugin for gedit to perform the encryption and decryption operation. But that is not supported in Ubuntu 12.04.

In search for some graphical means to encrypt and decrypt data on clipboard, I believe I have managed to connect all the dots to form a feasible solution. Here are the ingredients:
  1. Instead Seahorse (I used Synaptic Package Manager)
  2. Once installed, use Seahorse to import your private and your friends' keys.
  3. Make sure gnupg2 and gnupg-agent are installed.
  4. Install Emacs - either from the Ubuntu Software Centre
  5. Use Synaptic Package Manager to install easypg, an Emacs plug-in or from here.
Before one uses easypg, one needs to be aware that there is reported potential vulnerability. The combination of easypg and gnupg also throw up some curly configuration arrangement on caching the passphrase.

If you are decrypting material for the first time, the program will prompt for the passphrase and on its graphical dialog box, you can use Details link to open up the dialog box to reveal treatments of the passphrase allowing you to specify how long the passphrase can be discarded. Unfortunately there is no option to discard once used.

Now you are ready to perform the GnuPG operations using Emacs.

For those new to Emacs, here is a brief introduction materials on how best to use Emacs for encryption and decryption of materials via the clipboard:
  1. Open Emacs
  2. Use Buffers | *scratch* to switch into the scratch buffer so that what you type or paste into does not get saved into a file. In Emacs even if you do not explicitly save a file, the content is written to a form of temporary file whose name formed from the given file name. Something you want to avoid.
  3. Type your plain text or paste the cipher text into the buffer.
  4. Select the entire text block. (Use Edit | Select all).
  5. Then use Tools | Encryption/Decryption to bring up the sub-menu.
  6. Select Encrypt Region or Decrypt Region depending on your need at this time.
  7. If it is to encrypt the region, it will open up a split window on the bottom showing you brief instructions and a list of keys managed by Seahorse.
  8. Use Tab key to navigate to the key list, then press m to select and u to deselect the key.
  9. Once the keys are selected, click OK to perform the encryption and follow the prompt.
  10. If it is to decryption, it will prompt you for your passphrase and then it will cache it.

No comments:

Blog Archive