
git tag -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
)、git tag -u
コマンドはキーを取得し、期待どおりにタグに署名します。
これは、i3 wm を使用した Ubuntu 13.10 で発生しています。gnome-keyring が何らかの形で... を妨げているのではないかと疑っていますが、archlinux-arm を実行している Raspberry Pi では、同じように動作しますが、問題が少し異なります -- コマンドを実行した後git tag -u
、ロックを解除するためのパスワードを求められますが、pinentry またはプロンプトは表示されません。しばらくすると (約 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 -s
任意のファイルに直接アクセスしてキーのロックを解除し、gpg-agent に資格情報をキャッシュすると、タグは問題なく署名されます。
私の推測では、pinentry-curses の使い方に何か問題があるようです。/usr/bin/pinentry を /usr/bin/pinentry-curses を指すようにすでに更新しましたが、問題は解決しません。
何が間違っているのでしょうか? また、git を gpg/pinentry とうまく連携させるにはどうすればよいのでしょうか?
- Ubuntu 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/16
所有権はすでに になりますuser:tty
。
答え1
また、翻訳元新しい TTY を起動するたびに変数を設定します (bash/zsh rc ファイルから実行することもできます):
export GPG_TTY=$(tty)
答え2
Pinentry ncurses ダイアログの問題は、pinentry が使用しようとする TTY の所有権に関連しています (たとえば、最初にユーザーとしてログインし、次に su を実行した場合など)。
次のスクリプトをプロファイルこれを修正するには (マルチユーザー システムでは外側を省略するif
か、条件を != に変更する必要があります) :
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