Search code examples
linuxgitgithubgnupggpg-signature

Cannot sign commit with exported GPG key from other machine


I need help with gpg key in git. First I export keys from windows with this:

gpg --output backupkeys.pgp --armor --export-secret-keys --export-options export-backup user@email

Then on linux I import this key

gpg --import backupkeys.pgp 

and change from unknown to ultimate. So this is how I import this key to linux. But now I need add gpg key to git, so I do this:

git config --global user.signingkey mySuperKey

but when I can create commit

git commit -S -m "Super Commit" 

I have this output

error: gpg failed to sign the data
fatal: failed to write commit object

I don't know where is problem.


Solution

  • After trying exporting new GPG keys and later import. I found answare for this problem.

    echo hello world | gpg -sa -u user@email
    

    if I try this don't show this:

    gpg: signing failed: Inappropriate ioctl for device
    gpg: [stdin]: clear-sign failed: Inappropriate ioctl for device
    

    So all what I need to do is this:

    export GPG_TTY=$(tty)