development

Git 오류-GPG가 데이터에 서명하지 못했습니다.

big-blog 2020. 8. 18. 08:14
반응형

Git 오류-GPG가 데이터에 서명하지 못했습니다.


방금 git 사용을 시작했고 homebrew를 통해 git과 gpg를 설치했습니다. 어떤 이유로, git commit이 주제에 관한 다른 많은 스택 오버플로 질문을 보았을 때이 오류가 발생 했지만 그중 어느 것도 나를 위해 일하지 않았습니다. 성공적으로 업로드 할 수 있도록이 오류를 수정하려면 어떻게해야합니까?

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

문제 해결을 위해 먼저 시도해야 할 두 가지 사항 :

  • 실행 git config --global gpg.program gpg2확인 자식 사용을 만들기 위해, gpg2하지gpg
  • 실행 echo "test" | gpg2 --clearsign, gpg2자체 작동 하는지 확인

모든 것이 괜찮아 보인다면 다음으로 시도해보십시오.

  • brew install pinentry암호 입력을위한 좋은 도구가 설치되어 있는지 확인하기 위해 실행 하십시오.

설치 후 다시 시도해도 git commit" failed to sign the data"오류가 발생하는 경우 :

  • 실행 gpgconf --kill gpg-agent중단 할 수있는 실행중인 에이전트를 죽일

그 말한다면 gpgconf설치되어 있지 않거나이없는 --kill옵션을, 당신은 수있는 이 시도 :

  1. cp ~/.gnupg ~/.gnupg-GOOD~/.gnupg필요한 경우 나중에 되돌릴 사본을 저장 하려면
  2. brew install gnupg21 GnuPG 2.1을 설치하려면

당신의 사본을 저장하는 이유 ~/.gnupgDIR 때문에, / GnuPG는 2.1 잠재적으로 만들고 있다는 것이다 GnuPG는 2.0 이전 버전과의 호환 및 이전없는 방법으로 몇 가지 주요 데이터를 변경 하면 다시 나중에 가고, 당신이 할 수 싶어요 mv ~/.gnupg ~/.gnupg21 && mv ~/.gnupg-GOOD ~/.gnupg.


그렇지 않으면 GnuPG 환경이 작동하는지 확인하기 위해 실행할 몇 가지 기본 단계가 있습니다.

  • 을 실행 gpg2 -K --keyid-format SHORT하여 키 쌍이 하나 이상 있는지 확인하십시오.

출력 결과에 GnuPG가 사용할 비밀 키가 없다고 표시되면 하나를 만들어야합니다.

  • 를 실행 gpg2 --gen-key하여 GnuPG가 키 쌍을 만드는 단계를 안내하도록합니다.

“Inappropriate ioctl for device” 라는 오류 메시지가 나타나면 다음 과 같이하십시오.

  • 실행 export GPG_TTY=$(tty)및 / 또는 귀하의 ~/.bashrc또는˜/.bash_profile

Git은 서명하는 키를 알아야합니다.

GPG, gpg-agent 및 gpg.conf 파일 ( 이 가이드 참조 ) 을 설정 한 후 다음 을 실행해야합니다.

git config --global user.signingkey EB11C755

분명히 마지막에 공개 키를 자신의 것으로 바꾸십시오. 모든 커밋이 기본적으로 서명되도록하려면

git config --global commit.gpgsign true

어떻게 든 귀하의 자식은 모든 커밋에 GPG 서명하도록 구성됩니다. git을 사용하여 커밋하거나 푸시하는 데 GPG로 서명 할 필요가 없습니다. gpg 서명 메커니즘이 아직 구성되지 않았기 때문에 오류가 발생할 수 있습니다.

git을 처음 사용하는 경우 처음에는 GPG 서명없이 먼저 작동하도록 시도한 다음 정말로 필요한 경우 나중에 로그인을 추가하십시오.

다음을 수행하여 gpg와 관련하여 git이 구성되는 방법을 확인할 수 있습니다.

git config -l | grep gpg

다음을 포함하여 0 개 이상의 줄을 생성 할 수 있습니다.

commit.gpgsign=true

"commit.gpgsign"이 참이면 gpg 서명이 활성화 된 것입니다. 다음을 사용하여 비활성화하십시오.

git config --global --unset commit.gpgsign

그런 다음 커밋을 다시 실행하십시오. 이제 gpg 서명없이 실행되어야합니다. 기본 git이 작동하면 gpg 서명을 믹스에 다시 추가해야합니다.


@sideshowbarker 및 @Xavier Ho 솔루션을 참조하십시오. 다음 단계를 통해 문제를 해결했습니다.

brew가 gpg2를 설치했다고 가정합니다.

git config --global gpg.program gpg2
brew install pinentry
gpgconf --kill gpg-agent
gpg2 -K --keyid-format SHORT
// no key found then generate new one
gpg2 --gen-key

gpg2 -K --keyid-format SHORT 

... /. gnupg / pubring.gpg

sec rsa2048 / 0A61C6FC 2017-06-29 [SC] [만료 : 2019-06-29]

git config --global user.signingkey 0A61C6FC

동료가 상기시켜, 추가해야 함

export GPG_TTY=$(tty)

zsh를 사용하는 경우 ~ / .zshrc에, 그렇지 않으면 ~ / .bash_profile에 추가하십시오.


macOS의 경우

gpg2는 brew에서 gpg와 결합되므로 gpg 명령은 gpg2를 가리 킵니다.

brew install gpg2

양조 정보 gpg

gnupg : 안정 2.2.6 (병)

git config --global gpg.program gpg
gpg -K --keyid-format SHORT 

and there has pinentry-mac for passphrase entry

brew install pinentry-mac
vim ~/.gnupg/gpg-agent.conf

Add line

pinentry-program /usr/local/bin/pinentry-mac


I am using it. It has support for zsha and works on Windows Subsystem for Linux:

export GPG_TTY=$(tty)

Check for your key to be expired. Once you fix the expiration date (no need to create a new key unless you want to), git will work as normal.

One way to fix the expired key:

(Note: $ represents command line prompt, type the commands after the prompt; press Enter after each command)

$ gpg2 --list-keys to find the appropriate key id (characters after \ on pub line)

$ gpg2 --edit-key <key id> - this opens the gpg shell, with prompt changed to gpg>

gpg> expire - follow instructions to set new expiration date for primary key

Next, if there are subkeys that are expired (sub shows on the line), reset their expiration dates, too:

gpg> key 1 - selects first subkey gpg> expire - follow instructions to set new expiration date for subkey

Repeat for each subsequent subkey, as needed.


I experienced this problem after upgrading to gnupg 2.x. It would seen that gpg2 is referencing keys differently: I still had signingkey = ABC98F11 (gpg v1 setting) in my ~/.gitconfig. The key identifiers for gpg2 are longer. Look them up with gpg --list-secret-keys


This worked for me on ubuntu 18.04

Check your gpg key

gpg -K --keyid-format LONG

if you get a blank response ,generate a GPG key

gpg --generate-key

rerun the first command, you should get an output as:

sec   rsa3072/95A854E0593B3214 2019-05-06 [SC] [expires: 2021-05-05]
      AF2F7514568DC26B0EB97B9595A854E0593B74D8
uid                 [ultimate] yourname<your_email>
ssb   rsa3072/EFD326E6C611117C 2019-05-06 [E] [expires: 2021-05-05]

set git singing key

git config --global user.singingkey 95A854E0593B3214

then you are good to go! (--global is optional)

Alternatively if you dont mind signing with your ssh key

git config commit.gpgsign false

note that this is not recommended due to a security issue according to this question here and here


May be your Git config was set gpgsign = true. Try to set it to false if you dont want asign your commits. Go to your repository folder and change the file

nano .git/config

From this...

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = git@bitbucket.org:yourrepo/project.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[user]
    signingkey = <GPG-KEY>
[commit]
    gpgsign = true

To this...

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    url = git@bitbucket.org:yourrepo/project.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[user]
    signingkey = <GPG-KEY>
[commit]
    gpgsign = false

This error can also occur when your GPG key has expired. Generating a new key and adding it to Git should resolve this.


For me this error started to occur with git tag -s on Debian GNU/Linux when I switched from pinentry-gnome3 to pinentry-curses (using update-alternatives --config pinentry) for easier remote access. It only occurred with git tag -s, not with gpg (e.g. gpg --clearsign) itself.

The sole change necessary to get it working again in this case was to add export GPG_TTY=$(tty) to my shell startup files.

I though didn't get the “Inappropriate ioctl for device” error message mentioned as indicator for this fix in another answer to this question.

Note: Since the cause for getting this error was a completely different one than for those who suggested export GPG_TTY=$(tty) before (usually as a side hint) in other answers to this question, I decided this question needs another answer which mentions that export GPG_TTY=$(tty) may be the main fix and sole thing necessary in some cases.


I had made a git key with 3 separate keys for certify / sign / encrypt & the key showed as expired in the future (after working fine for a few days):

pub   rsa4096/4CD1E9DA 2017-04-26 [C] [expired: 2017-04-28]
      Key fingerprint = 4670 59C1 7592 08B8 7FA5  313B 2A42 B6A6 4CD1 E9DA
uid         [ expired] Stuart Cardall (GIT Development Keys) <xxxxxx>
sub   rsa4096/5195E715 2017-04-26 [E] [expired: 2019-04-26]
sub   rsa4096/DB74C297 2017-04-26 [S] [expired: 2019-04-26]
sub   rsa2048/A3913A3C 2017-04-28 [] [expired: never     ]

made a new key without adding separate subkeys to solve the problem.


I solved the problem installing brew install gpg2 then doing git config --global gpg.program gpg2


This will help you to get rid of it

git config commit.gpgsign false

참고URL : https://stackoverflow.com/questions/41052538/git-error-gpg-failed-to-sign-data

반응형