0%

迁移GPG密钥到另一台开发机

之前文章介绍了GPG签名,签名是为了防止提交被仿造。GPG签名也有一个问题:GPG签名被移除,之前提交的被签名的Commit将全部被标识为Unverify,因此不要随意删除GPG签名。通常开发者都有多台开发机,下面介绍如何迁移GPG签名。

查看存在的 GPG

1
2
3
4
5
6
$ gpg --list-keys
-------------------------------
pub rsa4096 2021-01-07 [SC]
C3DB73A9B0DE055246115ED2201DB741191B4EE3
uid [ultimate] luoji <luoji@example.com>
sub rsa4096 2021-01-07 [E]

导出密钥文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
$ gpg --export-secret-keys -a C3DB73A9B0DE055246115ED2201DB741191B4EE3 >private_key.asc

$ cat private_key.asc
-----BEGIN PGP PRIVATE KEY BLOCK-----

lQcYBF/3OqkBEADb8pfJIOl39W8wMWdERLK733Kn9k5ZVMG2QA4Ewo6Mf+gVlcYY
hqhgP7qn0ahMWkDJJcszdktKRuXs8FDh91dc+JKi9esnauWIQIJesQ/gEIBQM6mP
GvxI/6eI5+FK8PcxaZivlVV9exunUO6HpQTMxqDZ3NUN/i/K16FBeDP8gklJ7l56
5GSaShPRTaZOt6/dKg0v5viE5p0bhnZs5kpC7YPO/NtBibC8KlDXvDghmBQdn6uK
5hGAi2KaJOyLOiw0NnxvzAUku1wTUcl0XoWagYhJVdxB6i7dtbJxXu607Ls+CicB
FFLFOYe+Z+LsbCDhjKCUvsKBrbX1oF6FuAcS5CRFILH/a+ecJhLWFwzZgRIVM8ep
+0TZTVBmlGfwMj3vB06eUbj3YbAj+sF5wmfP2TtMH0Ua+62OoGN2pos6N0bs6QxC
71Az+jBP+Ibv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VLKtJK7tPR/uufUFG38nv53HhAX1WCLIVM9TLuA
dUaYSjzs24Q7g0G7BPhceJ2PcdHdqFnj/yOBT0v0vOesojAV0WcxnymNEE4tHvch
DdcDxtAqZDVz3H1e7PTEKf6cjceilhhQdETCkziJM4JdAo3lNCTuMA6u1XzLCGM3
ndbzXzwlAZNsugP1hV5OWR9T8rSZvnxcTC4ev3fTFPhU+TW4t1fvO68uLsbHyT+q
YUdsEyuqOSrEHGN6f4obv32W6xXKCs3olZtI+daEBNNPvVIyk8hfEXpnv/61ea4s
E6+fthpUH8DJ799YQyKbTEJtJrAES3tMBj4g/T9puAnORKHS9b9NbQXByb5YoNX3
mtw7jqJeBpuhzFlb1/BixGJTWKjSY9smg7oSa+Op1kOHLr1ddaSf2KbOp9ywbI8L
/SONu90os7LaMRE7k/FngpsHhfe6W1qW2VuelQei2Xmgt29SSHUZGJGdLbkWG8Y0
klW5+wfFax/EHd9Q1/w8l0HXLZgnrGIkPdJLPGNlO3OSC9xmJqJWTe2c3yvWfpnD
mcFf6irff/wgqixbzpTtoQzmqxgu7/5fNjSEl5qyFdo25cVlA9MntCBommvkvwc/
GOvAbuA2X4GSlPessZ+aC6xl9kk1axv2DdzM
=pbP9
-----END PGP PRIVATE KEY BLOCK-----
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
$ gpg --export -a C3DB73A9B0DE055246115ED2201DB741191B4EE3 >public_key.asc

$ cat public_key.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQINBF/3OqkBEADb8pfJIOl39W8wMWdERLK733Kn9k5ZVMG2QA4Ewo6Mf+gVlcYY
hqhgP7qn0ahMWkDJJcszdktKRuXs8FDh91dc+JKi9esnauWIQIJesQ/gEIBQM6mP
GvxI/6eI5+FK8PcxaZivlVV9exunUO6HpQTMxqDZ3NUN/i/K16FBeDP8gklJ7l56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Cm0dTktx5ajhurUIcFm/eVSyrSSu7T0f7rn1BRt/J7+dx4Q
F9VgiyFTPUy7gHVGmEo87NuEO4NBuwT4XHidj3HR3ahZ4/8jgU9L9LznrKIwFdFn
MZ8pjRBOLR73IQ3XA8bQKmQ1c9x9Xuz0xCn+nI3HopYYUHREwpM4iTOCXQKN5TQk
7jAOrtV8ywhjN53W8188JQGTbLoD9YVeTlkfU/K0mb58XEwuHr930xT4VPk1uLdX
7zuvLi7Gx8k/qmFHbBMrqjkqxBxjen+KG799lusVygrN6JWbSPnWhATTT71SMpPI
XxF6Z7/+tXmuLBOvn7YaVB/Aye/fWEMim0xCbSawBEt7TAY+IP0/abgJzkSh0vW/
TW0Fwcm+WKDV95rcO46iXgabocxZW9fwYsRiU1io0mPbJoO6EmvjqdZDhy69XXWk
n9imzqfcsGyPC/0jjbvdKLOy2jERO5PxZ4KbB4X3ultaltlbnpUHotl5oLdvUkh1
GRiRnS25FhvGNJJVufsHxWsfxB3fUNf8PJdB1y2YJ6xiJD3SSzxjZTtzkgvcZiai
Vk3tnN8r1n6Zw5nBX+oq33/8IKosW86U7aEM5qsYLu/+XzY0hJeashXaNuXFZQPT
J7QgaJpr5L8HPxjrwG7gNl+BkpT3rLGfmgusZfZJNWsb9g3czA==
=6rpY
-----END PGP PUBLIC KEY BLOCK-----

删除GPG密钥

1
2
3
4
5
6
7
8
9
10
$ gpg --list-secret-keys --keyid-format LONG
-------------------------------
sec rsa4096/201DB741191B4EE3 2021-01-07 [SC]
C3DB73A9B0DE055246115ED2201DB741191B4EE3
uid [ultimate] luoji <luoji@example.com>
ssb rsa4096/4F73374D480C0829 2021-01-07 [E]

$ gpg --delete-secret-keys 4F73374D480C0829

$ gpg --delete-keys C3DB73A9B0DE055246115ED2201DB741191B4EE3

导入GPG密钥

1
2
3
4
5
6
7
$ gpg --import private_key.asc
gpg: key 201DB741191B4EE3: public key "luoji <luoji@example.com>" imported
gpg: key 201DB741191B4EE3: secret key imported
gpg: Total number processed: 1
gpg: imported: 1
gpg: secret keys read: 1
gpg: secret keys imported: 1
1
2
3
4
$ gpg --import public_key.asc
gpg: key 201DB741191B4EE3: "luoji <luoji@example.com>" not changed
gpg: Total number processed: 1
gpg: unchanged: 1

查看导入密钥

1
2
3
4
5
$ gpg --list-secret-keys --keyid-format LONG
sec rsa4096/201DB741191B4EE3 2021-01-07 [SC]
C3DB73A9B0DE055246115ED2201DB741191B4EE3
uid [ unknown] luoji <luoji@example.com>
ssb rsa4096/4F73374D480C0829 2021-01-07 [E]

密钥被导入了,想要将GPG密钥导入其它机器,只需拷贝文件后再导入。