Gpg2 won't generate a keypair

gpg2 won’t generate a keypair. It says Key generation failed: SQL library used incorrectly. If it matters, the words in my passphrase are each preceeded by ]
This problem caused me to reinstall openSuse Tumbleweed an hour ago, and it still persists. I didn’t erase /home , so I’m guessing there’s something in there causing trouble. What do I delete so that this will work?

Hello and welcome to the openSUSE forums.

This is nice story telling, but we love it to see what really happens. Thus you better copy/paste what you do on the terminal, starting with the line with the prompt and the command, then all output up to and including the new prompt (that will show us that it is complete).

Please paste that as Code/Preformatted text by e.g. using the button </> from the tool bar of the post editor.

BanisterJH@localhost:~> gpg2 --full-gen-key
gpg (GnuPG) 2.5.13; Copyright (C) 2025 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

can't connect to 'socket:///home/BanisterJH/.gnupg/log-socket': Connection refused
Please select what kind of key you want:
   (1) RSA and RSA
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
   (9) ECC (sign and encrypt) *default*
  (10) ECC (sign only)
  (14) Existing key from card
  (16) ECC and Kyber
Your selection? 9
Please select which elliptic curve you want:
   (1) Curve 25519 *default*
   (4) NIST P-384
   (6) Brainpool P-256
Your selection? 1
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 5y
Key expires at Mon 25 Nov 2030 02:00:40 AM PST
Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key.

Real name: John Harry Banister
Email address: John@Banister.name
Comment: ---
You selected this USER-ID:
    "John Harry Banister (---) <John@Banister.name>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
Key generation failed: SQL library used incorrectly
BanisterJH@localhost:~> 

I cannot reproduce it. Are you prompted for the passphrase?

Yes. I copy and pasted
]Tingle ]Provider ]Amusement ]Lard ]Tilt ]Dreamy ]Tribesmen
from KeypassXC
Is there anything I can delete in /home that would help reset it?

I should point out that I used this same passphrase all last year successfully.

Still works. Sorry, I do not know. Try to do the same with a clean empty keyring:

mkdir /tmp/kr
gpg2 --keyring /tmp/kr --no-default-keyring --full-gen-key

I haven’t completed this as I immediately got

gpg: Note: Specified keyrings are ignored due to option "use-keyboxd"

I have nothing useful on any keyring. Are there files I can delete to remove every keyring and saved option?

I went ahead and completed the process with the same

Key generation failed: SQL library used incorrectly

Then I supposed you can rename ~/.gnupg.

I did that. First key generation failed because it couldn’t fine .gnupg
Then I ran gpg2 without arguments, and it created .gnupg
Then I tried again with

gpg2 --full-gen-key

and got

gpg: Note: database_open 134217901 failed to create temporary file '/home/BanisterJH/.gnupg/public-keys.d/.#lk0x00007f86b0000ce0.localhost.localdomain.2993': No such file or directory
gpg: keydb_search failed: No such file or directory
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: Note: database_open 134217901 failed to create temporary file '/home/BanisterJH/.gnupg/public-keys.d/.#lk0x00007f86b0000ce0.localhost.localdomain.2993': No such file or directory
gpg: keydb_search failed: No such file or directory
gpg: error writing public keyring '[keyboxd]': SQL library used incorrectly
Key generation failed: SQL library used incorrectly

Does this directory exist?

No. There was one file: common.conf and one folder: private-keys-v1.d
However, I opened common.conf with Kate and there was only the words: use keyboxd
on line one. I backpaced that right out of existence, saved my changes, and tried again. This time I had success! Apparently keyboxd can’t correctly use SQLite on my system, even after I reinstalled.

I should add that after my success, it added the folder: openpgp-revocs.d
and the files pubring.kbx pubring.kbx~ and trustdb.gpg
Now, I’ll generate a new passphrase, delete that folder once again, and start over
without the assistance of keyboxd

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.