解決在MacOS中配置GPG簽名使用於VSCode內失敗問題

問題描述

本文旨在解決MacOS設定GPG用於GIT執行 git commit -s時出現以下錯誤

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

此故障也可能出現於 echo “Something” | gpg –clearsign 及 VSCode執行commit簽名時

發生原因

gpg執行緒在某些shell或之外的區域可能呼叫用於輸入密碼的套件,或者需要GUI的密碼輸入介面.

解決方案

.允許gpg使用gpg-agent

echo 'use-agent' >> ~/.gnupg/gpg.conf

.安裝用於GUI介面下輸入密碼的套件pinentry-mac

brew install pinentry-mac

.設定pinentry-mac 使用於 gpg

echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf

.重新啟動gpg-agent

killall gpg-agent

.done. 完成

發佈留言