Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Export Private / Secret ASC Key to Decrypt GPG Files

Background: My boss has tried exporting an ASC key to me with public and private parts but whenever I get the file the private part never loads up and it won't decrypt any files.

We have tried Exporting the ASC Key using:

  • Windows Application Kleopatra 2.1 (included in gpg4win)
  • Windows Application GNU Privacy Assistant (included in gpg4win)

            Error: "Decryption failed. Secret Key Not available."  

How do you properly export a secret or private asc key to decrypt gpg files?

like image 477
Brian McCarthy Avatar asked Apr 07 '11 20:04

Brian McCarthy


People also ask

Where is GPG private key stored?

Types of GPG keys The private GPG keys are encrypted and stored in the secret keyring, and public keys are maintained with certificates attesting to their trustworthiness in the public keyring. You can use the public key for the data encryption, and that encrypted data will be decrypted using the Private key.


1 Answers

You can export the private key with the command-line tool from GPG. It works on the Windows-shell. Use the following command:

gpg --export-secret-keys 

A normal export with --export will not include any private keys, therefore you have to use --export-secret-keys.

Edit:

To sum up the information given in my comments, this is the command that allows you to export a specific key with the ID 1234ABCD to the file secret.asc:

gpg --export-secret-keys --armor 1234ABCD > secret.asc 

You can find the ID that you need using the following command. The ID is the second part of the second column:

gpg --list-keys 

To Export just 1 specific secret key instead of all of them:

gpg --export-secret-keys keyIDNumber > exportedKeyFilename.asc 

keyIDNumber is the number of the key id for the desired key you are trying to export.

like image 113
Demento Avatar answered Oct 18 '22 08:10

Demento