GPG签名报错error: gpg failed to sign the data:
环境: Ubuntu24.04
今天在学习给github添加gpg签名,签名时提示
error: gpg failed to sign the data:
[GNUPG:] KEY_CONSIDERED 6Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 2
[GNUPG:] BEGIN_SIGNING H10
[GNUPG:] PINENTRY_LAUNCHED 591451 curses 1.2.1 - xterm localhost:10.0 - 0/0 -
gpg: signing failed: Inappropriate ioctl for device
[GNUPG:] FAILURE sign 8xxxxxxx
gpg: signing failed: Inappropriate ioctl for device
fatal: failed to write commit object
想起之前整vscode远程开发环境时在.bashrc里写过export DISPLAY="localhost:11.0"
,手动export不好使,查到设置
export GPG_TTY=$(tty)
添加到.bashrc,再登录git commit -S 就能弹出输入phrase界面。
顺便说一下如何添加GPG密钥
1.生成密钥
gpg --full-generate-key
前三个回车,然后输入y,输入用户名和邮件地址(github邮件地址),输入O。
2.导出GPG公钥
gpg --export -a [email protected]
将输出的内容复制,粘贴到github settings->SSH AND GPG Keys->New GPG key
客户端需要做的,查看密钥ID
gpg -k --keyid-format LONG
设置默认签名密钥,将xxxxx换成密钥ID。
git config --global user.signingkey xxxxx
需要签名时 -S即可签名
git commit -S -m "hello"
如需默认自动签名,可
git config --global commit.gpgsign true
阅读剩余
版权声明:
作者:konoha
链接:https://konoha.cc/gpg%e7%ad%be%e5%90%8d%e6%8a%a5%e9%94%99.html
文章版权归作者所有,未经允许请勿转载。
THE END