Not able to login to git-crypt because .gnupg/pubring.kbx file messed up

649 Views Asked by At

I have messed up .gnupg/pubring.kbx file. I don't have any backup of the .gnupg folder. But still, I have my GPG Public and Private keys. I am unable to unlock git-crypt. When I list the .gnupg folder in my mac, lt lists these files:

S.gpg-agent  S.gpg-agent.extra  openpgp-revocs.d  pubring.kbx
trustdb.gpg  S.gpg-agent.browser  S.gpg-agent.ssh
private-keys-v1.d  pubring.kbx~

Is there any way to recover back that file so that I can do git-crypt unlock? OR Is there any way to do git-crypt unlock without that file?

1

There are 1 best solutions below

0
On BEST ANSWER

Since, you have your public and private key in hand. Here are the steps you will need to follow:

  1. Goto your gnugp dir

    cd ~/.gnupg
    
  2. Deleting the corrupted pubring.kbx

    rm pubring.kbx
    
  3. Copy pubring.kbx~ as pubring.kbx. This will give you an empty pubring which will not have any secret keys. Its like a fresh start.

    cp pubring.kbx~ pubring.kbx
    
  4. Import your public key

    gpg --import <your-public-key-file.asc>
    

Good luck!