I've export my gpg key from the machine they were created to another server.

In the new server I've tried to use the imported key to decrypt some files I've received, but I got the following error:

gpg: encrypted with 1024-bit RSA key, ID 0A83CFB1, created 2014-09-09
      "App Eng <appeng@dx.com>"
gpg: public key decryption failed: Bad passphrase
gpg: decryption failed: No secret key

I'm sure that the passphrase I've used is correct. I then tried to edit my key and change the passphrase doing:

gpg --list-keys

pub   2048R/DB437C11 2016-04-29 [expires: 2018-04-29]
uid       [ unknown] App Eng (ibm keys) <appeng@dx.com>
sub   2048R/0AC6B02C 2016-04-29 [expires: 2018-04-29]

pub   1024R/AADE6532 2014-09-09
uid       [ unknown] App Eng <appeng@dx.com>
sub   1024R/0A83CFB1 2014-09-09

gpg --edit-key AADE6532
gpg (GnuPG) 2.0.28; Copyright (C) 2015 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Secret key is available.

pub  1024R/AADE6532  created: 2014-09-09  expires: never       usage: SC  
                     trust: unknown       validity: unknown
sub  1024R/0A83CFB1  created: 2014-09-09  expires: never       usage: E   
[ unknown] (1). App Eng <appeng@dx.com>

gpg> passwd
Key is protected.

You need a passphrase to unlock the secret key for
user: "App Eng <appeng@dx.com>"
1024-bit RSA key, ID AADE6532, created 2014-09-09

gpg: cancelled by user
Can't edit this key: Operation cancelled

This makes me think that there has been some issue with importing the keys. Can anyone understand why I can't decrypt my files with the key installed? Thanks!

  • Can you edit the passphrase on the source machine and re-import it on the remote machine? – wulfgarpro Jun 22 '16 at 10:15
  • hey @wulfgarpro I can't even edit on the source machine, I got this error: gpg --edit-key AADE6532 Command> passwd Key is protected. can't connect to `/opt/dx/dxuser/.gnupg/S.gpg-agent': Connection refused You need a passphrase to unlock the secret key for user: "App Eng <appeng@dx.com>" 1024-bit RSA key, ID AADE6532, created 2014-09-09 gpg-agent[12290]: command get_passphrase failed: Operation cancelled gpg: cancelled by user Can't edit this key: General error – AlessioG Jun 22 '16 at 14:16
  • sounds like you've forgotten your passphrase :) – wulfgarpro Jun 23 '16 at 11:34
  • no, I can't even put in my passphrase. The issue is not I forgot. – AlessioG Jun 23 '16 at 14:59
  • The error suggests gpg cannot connect to gpg-agent, not that you forgot your passphrase. Is gpg-agent really running (pgrep -a gpg-agent)? What gpg version are you using? – Matei David Aug 4 '16 at 2:00

This link has the answer: https://lists.gnupg.org/pipermail/gnupg-users/2013-April/046559.html

The special user which runs the apps on this host, doesn't have the proper TTY rights when I sudo to it. So, gpg being unable to show the TTY GUI, just fails without giving the real reason. In order to be able to do this I had to exit my navsrv sudo session, and make the following call:

chmod o+rw `tty` && sudo -i -u navsrv gpg --edit-key 8267977F

Next, I entered the navsrv login password. Then, at the gpg command prompt, when I did "passwd", I got the Enter Passphrase GUI.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.