[windows-xp] GnuPG: "decryption failed: secret key not available" error from gpg on Windows

Environment: HP laptop with Windows XP SP2

I had created some encrypted files using GnuPG (gpg) for Windows. Yesterday, my hard disk failed so I had reimage the hard disk. I have now reinstalled gpg and regenerated my keys using the same passphrase as earlier. But, I am now unable to decrypt the files. I get the following error:


C:\sureshr>gpg -a c:\sureshr\work\passwords.gpg
gpg: encrypted with 1024-bit ELG-E key, ID 279AB302, created 2008-07-21
      "Suresh Ramaswamy (AAA) BBB"
gpg: decryption failed: secret key not available

C:\sureshr>gpg --list-keys
C:/Documents and Settings/sureshr/Application Data/gnupg\pubring.gpg
--------------------------------------------------------------------
pub   1024D/80059241 2008-07-21
uid                  Suresh Ramaswamy (AAA) BBB
sub   1024g/279AB302 2008-07-21

AAA = gpg comment
BBB = my email address

I am sure that I am using the correct passphrase. What exactly does this error mean? How do I tell gpg where to find my secret key?

Thanks,

Suresh

This question is related to windows-xp gnu gnupg

The answer is


You need to import not only your secret key, but also the corresponding public key, or you'll get this error.


when reimporting your keys from the old keyring, you need to specify the command:

gpg --allow-secret-key-import --import <keyring>

otherwise it will only import the public keys, not the private keys.


workmad3 is apparently out of date, at least for current gpg, as the --allow-secret-key-import is now obsolete and does nothing.

What happened to me was that I failed to export properly. Just doing gpg --export is not adequate, as it only exports the public keys. When exporting keys, you have to do

gpg --export-secret-keys >keyfile

Yes, your secret key appears to be missing. Without it, you will not be able to decrypt the files.

Do you have the key backed up somewhere?

Re-creating the keys, whether you use the same passphrase or not, will not work. Each key pair is unique.


One more cause for the "secret key not available" message: GPG version mismatch.

Practical example: I had been using GPG v1.4. Switching packaging systems, the MacPorts supplied gpg was removed, and revealed another gpg binary in the path, this one version 2.0. For decryption, it was unable to locate the secret key and gave this very error. For encryption, it complained about an unusable public key. However, gpg -k and -K both listed valid keys, which was the cause of major confusion.


The resolution to this problem for me, was to notify the sender that he did use the Public key that I sent them but rather someone elses. You should see the key that they used. Tell them to use the correct one.


Questions with windows-xp tag:

installing JDK8 on Windows XP - advapi32.dll error How to Create a script via batch file that will uninstall a program if it was installed on windows 7 64-bit or 32-bit How do I find files with a path length greater than 260 characters in Windows? Apache Maven install "'mvn' not recognized as an internal or external command" after setting OS environmental variables? How to access share folder in virtualbox. Host Win7, Guest Fedora 16? How to create ls in windows command prompt? How to fix an UnsatisfiedLinkError (Can't find dependent libraries) in a JNI project How to use random in BATCH script? How to delete or change directory of a cloned git repository on a local computer How do I manually create a file with a . (dot) prefix in Windows? For example, .htaccess Vim for Windows - What do I type to save and exit from a file? BAT file to open CMD in current directory IF EXIST C:\directory\ goto a else goto b problems windows XP batch files Download the Android SDK components for offline install How do you copy and paste into Git Bash How to start MySQL server on windows xp intl extension: installing php_intl.dll How do I free my port 80 on localhost Windows? How do I run a bat file in the background from another bat file? Opening a remote machine's Windows C drive How to export and import environment variables in windows? Maximum filename length in NTFS (Windows XP and Windows Vista)? Launching an application (.EXE) from C#? Windows could not start the Apache2 on Local Computer - problem What's the fastest way to delete a large folder in Windows? How do I install cURL on Windows? How to schedule a task to run when shutting down windows GnuPG: "decryption failed: secret key not available" error from gpg on Windows How to loop through files matching wildcard in batch file

Questions with gnu tag:

gcc-arm-linux-gnueabi command not found grep --ignore-case --only How to Export Private / Secret ASC Key to Decrypt GPG Files grep regex whitespace behavior Compiling a C++ program with gcc Passing additional variables from command line to make How to display line numbers in 'less' (GNU) How do I apply a diff patch on Windows? How do I syntax check a Bash script without running it? GnuPG: "decryption failed: secret key not available" error from gpg on Windows

Questions with gnupg tag:

gpg decryption fails with no secret key error How to resolve "gpg: command not found" error during RVM installation? Can't check signature: public key not found How to display gpg key details without importing it? How to Export Private / Secret ASC Key to Decrypt GPG Files How to trust a apt repository : Debian apt-get update error public key is not available: NO_PUBKEY <id> GnuPG: "decryption failed: secret key not available" error from gpg on Windows