文字错误 #160
P241: gpg: signing failed: 私钥不可用
| Status: | 已关闭 | Start date: | 08/03/2011 | |
|---|---|---|---|---|
| Priority: | 普通 | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | - | Spent time: | - | |
| Target version: | 第一版 |
Description
我在测试第241页内容(带签名的里程碑)时出现了下面问题,不知该如何解决。
按照书中说的,先用GPG生成了user1的key,然后执行
$ git tag -s -m "My first GPG-signed tag." mytag3
结果出现私钥不可用的现象,如下:
gpg: “user1 <user1@sun.ossxp.com>”已跳过:私钥不可用 gpg: signing failed: 私钥不可用 error: gpg failed to sign the tag error: unable to sign the tag
我在网上搜,发现有人也遇到这个问题了:
已经用 gpg --gen-key生成了密匙,但是签署标签时失败。 $ git tag -s v1.5 -m 'my signed 1.5 tag' gpg: “Aaron Xu <greatsn...@gmail.com>”已跳过:私钥不可用 gpg: signing failed: 私钥不可用 error: gpg failed to sign the tag error: unable to sign the tag help!! -- Aaron Xu
不知你遇到过没有?
History
#1
Updated by 蒋 鑫 10 months ago
可能是大小写问题:创建的公钥-私钥对,用的用户名是大写 User1,而提交者用户名是小写 user1。
对比一下下面两个命令的输出,看看是否匹配:
$ gpg --list-keys $ git log -1 --pretty=fuller
;-)
#2
Updated by 蒋 鑫 10 months ago
我本地用 git 1.5.5 到 1.7.6 很多版本试验,发现 user.name 设定的用户名的大小写和公钥-私钥对中用户名大小写无关,即大小写不敏感,可以创建签名里程碑。
还是把你的公钥-私钥对列出来。
还有,关于问题的讨论还是放在GotGit微群里好,因为会有更多人看到和回复。
#4
Updated by 王 胜 10 months ago
下面是我的本地环境:
wangsheng@ubuntu:~/work/user1/hello-world$ git --version git version 1.7.1 wangsheng@ubuntu:~/work/user1/hello-world$ gpg --version gpg (GnuPG) 1.4.10
下面是对用户大小写测试的结果:
wangsheng@ubuntu:~/work/user1/hello-world$ gpg --list-keys /home/wangsheng/.gnupg/pubring.gpg ---------------------------------- pub 2048R/9ABB0388 2011-08-03 uid Wang Sheng (My signed of 163 email.) <wangsheng...@163.com> sub 2048R/DFE21BB6 2011-08-03 pub 2048R/11C86D54 2011-08-03 uid user1 (user1 signed of ossxp email.) <user1@sun.ossxp.com> sub 2048R/70B19548 2011-08-03 wangsheng@ubuntu:~/work/user1/hello-world$ git config user.name user1
我这里的user1都是小写创建的。
btw:这个帖子是我搜的,和我遇到了相同的问题。http://groups.google.com/group/progit-zh/browse_thread/thread/13cc2e8d43749e26
#5
Updated by 王 胜 10 months ago
我用-u 参数制定key这条命令成功创建了签名的tag。
wangsheng@ubuntu:~/work/user1/hello-world$ git tag -s -m "My first GPG-signed tag." mytag3 gpg: “user1 <user1@sun.ossxp.com>”已跳过:私钥不可用 gpg: signing failed: 私钥不可用 error: gpg failed to sign the tag error: unable to sign the tag wangsheng@ubuntu:~/work/user1/hello-world$ git tag -u user1 -m "My first GPG-signed tag." mytag3 wangsheng@ubuntu:~/work/user1/hello-world$ git tag -v mytag3 object f83974b8e4aec0770914c4abe48399ab472cf502 type commit tag mytag3 tagger user1 <user1@sun.ossxp.com> 1312377362 +0800 My first GPG-signed tag. gpg: 于 2011年08月03日 星期三 21时16分02秒 CST 创建的签名,使用 RSA,钥匙号 11C86D54 gpg: 完好的签名,来自于“user1 (user1 signed of ossxp email.) <user1@sun.ossxp.com>”
#6
Updated by 蒋 鑫 10 months ago
哈哈看出你的错误了。先来看看我的 gpg --list-keys 的输出
$ gpg --list-keys /Users/jiangxin/.gnupg/pubring.gpg ---------------------------------- ... pub 2048R/37379C67 2011-01-02 uid User1 <user1@sun.ossxp.com> sub 2048R/2FCFB3E2 2011-01-02
而你为 user1 建立的公钥-私钥对,用户名不是 user1,而是一大串“user1 (user1 signed of ossxp email.) ”,如果你执行 git config user.name "user1 (user1 signed of ossxp email.) " 然后打 tag 肯定可以自动选择公钥,不过这不是你想要的,还是重建一份公钥-私钥对。我很好奇圆括号中的文字是如何产生的,愿闻其详。
#7
Updated by 王 胜 10 months ago
恩,确实是你说的这个问题造成的,我按照你说的执行以下命令:
wangsheng@ubuntu:~/work/user1/hello-world$ git config user.name "user1 (user1 signed of ossxp email.)" wangsheng@ubuntu:~/work/user1/hello-world$ git tag -s -m "HELLO GPG-signed tag." mytagA wangsheng@ubuntu:~/work/user1/hello-world$ git tag -v mytagA object f0922a39970d2ce0d6cdea29806946bf227841fc type commit tag mytagA tagger user1 (user1 signed of ossxp email.) <user1@sun.ossxp.com> 1312420324 +0800 HELLO GPG-signed tag. gpg: 于 2011年08月04日 星期四 09时12分04秒 CST 创建的签名,使用 RSA,钥匙号 11C86D54 gpg: 完好的签名,来自于“user1 (user1 signed of ossxp email.) <user1@sun.ossxp.com>”
其实圆括号中的文字是在GPG创建钥环时
您需要一个用户标识来辨识您的密钥;本软件会用真实姓名、注释和电子邮件地址组合
成用户标识,如下所示:
“Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>”
真实姓名: user2
电子邮件地址: user2@moon.ossxp.com
注释:user2 signed of ossxp email.
在注释后输入的文本,目的是对该密钥加一条注释。但谁知在这里却被作为key-id解析了,看来git tag -s 这条命令有点小问题了(不知在高于1.7.1版本的有没有这个问题,你试下。如果也有,建议你在《Git 权威指南》该章节处用一个注释说明一下在用gpg创建密钥时不要填写注释内容)。