gpg-agent 및 pinentry-curses가 포함된 git 태그

gpg-agent 및 pinentry-curses가 포함된 git 태그

git 태그 -u와 함께 gpg-agent를 사용하면 즉시 다음 오류가 발생합니다.

gpg: cancelled by user
gpg: skipped "[email protected]": bad passphrase
gpg: signing failed: bad passphrase
error: gpg failed to sign the data
error: unable to sign the tag

gpg-agent.conf:

pinentry-program /usr/bin/pinentry-curses

gpg -e -s test.txt먼저 a 를 통해 키를 잠금 해제하면 git tag -u명령이 키를 선택하고 예상대로 태그에 서명합니다.

이것은 i3 wm을 사용하는 우분투 13.10에서입니다. gnome-keyring이 왠지 방해가 되는 것 같은데...뭔가 문제가 있지만, 라즈베리 파이에서는 Archlinux-arm을 실행하면 같은 방식으로 작동하지만 약간 다른 문제가 있습니다. -- 명령을 실행한 후 다음을 git tag -u요청합니다. 잠금을 해제하려면 비밀번호를 입력해야 하지만 핀트리나 프롬프트가 나타나지 않습니다. 일정 시간(약 30초)이 지나면 다음과 같이 실패합니다.

gpg: problem with the agent: Line passed to IPC too long
gpg: skipped "[email protected]": Operation cancelled
gpg: signing failed: Operation cancelled
error: gpg failed to sign the data
error: unable to sign the tag

다시 말하지만, gpg-agent에서 자격 증명을 캐시하기 위해 임의의 파일로 직접 키를 잠금 해제하면 gpg -s태그가 문제 없이 서명됩니다.

내 가정은 pinentry-curses를 사용하는 데 뭔가 이상하다는 것입니다. /usr/bin/pinentry-curses를 가리키도록 /usr/bin/pinentry를 이미 업데이트했지만 문제가 지속됩니다.

내가 뭘 잘못하고 있는 걸까요? Git이 gpg/pinentry를 잘 사용하도록 하려면 어떻게 해야 하나요?

  • 우분투 GPG 버전: 1.4.14
  • Archlinux-arm GPG 버전: gnupg-2.0.22-1

편집: zsh를 실행 중입니다. 다음은 gpg 에이전트에 대한 관련 비트 소스입니다.

if [ $EUID -ne 0 ] ; then
    envfile="$HOME/.gnupg/gpg-agent.env"
    if [[ -e "$envfile" ]] && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
        eval "$(cat "$envfile")"
    else
        eval "$(gpg-agent --daemon --write-env-file "$envfile")"
    fi
    export GPG_AGENT_INFO  # the env file does not contain the export statement
fi

$(tty)(예: )를 팔로우하면 /dev/pts/16ownsership이 이미 입니다 user:tty.

답변1

또한GPG_TTY새 TTY를 시작할 때마다 변수를 설정합니다(bash/zsh rc 파일에서도 수행할 수 있음).

export GPG_TTY=$(tty)

답변2

Pinentry ncurses 대화 상자의 문제는 사용하려고 하는 TTY pinentry의 소유권과 관련이 있습니다(예를 들어 처음에 사용자로 로그인한 다음 su로 로그인하는 경우).

다음 스크립트를/etc/profile.d/gpg-agent.shif문제를 해결하려면 ( 다중 사용자 시스템에서 외부를 생략하거나 조건을 !=로 변경할 수 있습니다 ):

if [ "$(id -un)" = "root" ] ; then
    envfile="$HOME/.gnupg/gpg-agent.env"
    if [[ -e "$envfile" ]] && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
        eval "$(cat "$envfile")"
    else
        eval "$(gpg-agent --daemon --enable-ssh-support --write-env-file "$envfile")"
    fi

    export GPG_AGENT_INFO    # the env file does not contain the export statement
    export SSH_AUTH_SOCK     # enable gpg-agent for ssh

    GPG_TTY=$(tty)
    chown $USER:tty $GPG_TTY # make pinentry-ncurses work
fi

관련 정보