21

I'm trying to generate a gpg key

$ gpg --full-gen-key

but eventurally I get an error

gpg: agent_genkey failed: No such file or directory
Key generation failed: No such file or directory

I'm on Arch Linux.

$ gpg --version
gpg (GnuPG) 2.1.15
libgcrypt 1.7.3
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /home/me123/.gnupg
.............

The directory /home/me123/.gnupg exists

  • 3
    Run strace -o /tmp/foo gpg --full-gen-key and then review the output. Should then be clear what file or directory it's not finding. – steve Oct 23 '16 at 20:04
  • 1
    If that doesn't solve it, you could also start gpg-agent with strace, just in case the error comes from there: pkill gpg-agent; strace -o /tmp/gpg-agent.trace gpg-agent --daemon. – Matei David Oct 24 '16 at 14:47
21

Did you delete the /home/me123/.gnupg directory and then it was recreated by gpg? If so, that's likely what is confusing the agent.

Either restart the agent (gpgconf --kill gpg-agent) or, more drastically, reboot your machine and try again.

14

It would appear that the directory ~/.gnupg/private-keys-v1.d (under some circumstances) is not being created or, is created with the wrong permissions.

# mkdir -p ~/.gnupg/private-keys-v1.d
# chmod 700 ~/.gnupg/private-keys-v1.d

Fixed it for me.

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.