I tried to generate my keys in a headless environment using this command:
gpg --full-gen-key --debug-all
At first, I got this error:
https://bugs.archlinux.org/task/29199
I tought I had fixed the problem with the pinentry-program
/usr/bin/pinentry-curses line in my gpg-agent.conf file but I got another error:
gpg: enabled debug flags: packet mpi crypto filter iobuf memory cache memstat
trust hashing cardio ipc clock lookup extprog
gpg: DBG: [not enabled in the source] start
gpg: DBG: chan_4 <- OK Pleased to meet you, process 12393
gpg: DBG: connection to agent established
gpg: DBG: chan_4 -> RESET
gpg: DBG: chan_4 <- OK
gpg: DBG: chan_4 -> OPTION ttyname=/dev/tty1
gpg: DBG: chan_4 <- OK
gpg: DBG: chan_4 -> OPTION ttytype=linux
gpg: DBG: chan_4 <- OK
gpg: DBG: chan_4 -> OPTION lc-ctype=C
gpg: DBG: chan_4 <- OK
gpg: DBG: chan_4 -> OPTION lc-messages=C
gpg: DBG: chan_4 <- OK
gpg: DBG: chan_4 -> OPTION allow-pinentry-notify
gpg: DBG: chan_4 <- OK
gpg: DBG: chan_4 -> OPTION agent-awareness=2.1.0
gpg: DBG: chan_4 <- OK
gpg: DBG: chan_4 -> AGENT_ID
gpg: DBG: chan_4 <- ERR 67109139 Unknown IPC command <GPG Agent>
gpg: DBG: chan_4 -> RESET
gpg: DBG: chan_4 <- OK
gpg: DBG: chan_4 -> GENKEY
gpg: DBG: chan_4 <- S INQUIRE_MAXLEN 1024
gpg: DBG: chan_4 <- INQUIRE KEYPARAM
gpg: DBG: chan_4 -> D (genkey(rsa(nbits 4:2048)))
gpg: DBG: chan_4 -> END
gpg: DBG: chan_4 <- INQUIRE PINENTRY_LAUNCHED 12396
gpg: DBG: chan_4 -> END
gpg: DBG: chan_4 <- ERR 83886179 Operation cancelled <Pinentry>
gpg: agent_genkey failed: Operation cancelled
gpg: DBG: [not enabled in the source] stop
gpg: random usage: poolsize=600 mixed=0 polls=0/0 added=0/0
outmix=0 getlvl1=0/0 getlvl2=0/0
gpg: secmem usage: 1344/32768 bytes in 2 blocks
It seems related to pinentry but the error message only states that pinentry
cancelled the key generation without any further details.