I have a problem with gpg2 and signing my commits in git. I should preface all this by saying this all worked yesterday before I did an apt-get update && apt-get upgrade and a reboot.

Now when I try to sign my commits I get the following error message:

gpg: skipped "3C27FEA3B5758D9E": No secret key
gpg: signing failed: No secret key
error: gpg failed to sign the data
fatal: failed to write commit object

Actually, I seem to get it when I try to stash my changes too.

When I do a pgrep I can see that gpg-agent is running so I've killed it and restarted it.

I have also have this in my .bashrc file:

export GPG_TTY=$(tty)

Output of gpg2 --list-keys /home/mdhas/.gnupg/pubring.gpg:

pub   rsa2048/FBJJJJ1C 2017-10-11 [SC]
uid         [ultimate] Mark Dhas <[email protected]>
sub   rsa2048/3FDJJJJJ 2017-10-11 [E]

pub   rsa2048/BFJJJJJ7 2017-11-17 [SC]
uid         [ultimate] Mark Dhas <[email protected]>
sub   rsa2048/DEDDJJJJ 2017-11-17 [E]

pub   rsa4096/7137JJJJ 2017-10-11 [SC] [expires: 2021-10-11]
uid         [ unknown] co.co <[email protected]>
sub   rsa4096/A9BJJJJJ 2017-10-11 [E] [expires: 2021-10-11]

pub   rsa4096/B57JJJJJ 2018-10-31 [SC] [expires: 2021-10-31]
uid         [ unknown] Mark Dhas (New Key-Created on 2018-10-31) <[email protected]>
sub   rsa4096/36FJJJJJ 2018-10-31 [E] [expires: 2021-10-31]

Please ignore the JJJJJ's they are an attempt at a small amount of redaction for security purposes.

$ gpg2 --list-secret-keys
sec   rsa2048/FBJJJJ1C 2017-10-11 [SC]
uid         [ultimate] Mark Dhas <[email protected]>
ssb   rsa2048/3FDJJJJJ 2017-10-11 [E]

And this is a section of my git config

user.name=Mark Dhas
[email protected]

Any ideas on how to rectify this issue would be great.

  • I should also note that I created the gpg key on my macbook and then exported the public key to my ubuntu server. Importing it there with a gpg2 --import <filename>
    – Mark D
    Oct 31, 2018 at 18:26

1 Answer 1


You don't have the private part of your GPG key. A GPG key consists of a public key, the piece of information that other computers can use to verify signatures coming from you, and the private key, the part that is needed to create a signature or decrypt messages sent to you. This is why Git is giving you an error. It can't get the private key to sign the commit. Your only option is to find a backup of the entire key (one that includes the private key), or to create a new key.

  • 1
    You may want to add "How to export a GPG secret key".... gpg --output private_key.asc --armor --export-secret-keys [email protected] Oct 31, 2018 at 22:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .