首先,您需要检查您的 ID 是否有 gpg 密钥。
$ gpg --list-key
如果你有应该出现这样的东西:
- 酒馆 2048R/6AB3587A 2013-05-23
- uid xxx(用于 xxx 的 gpg)
- 子 2048R/64CB327A 2013-05-23
如果没有 gpg 密钥。你应该创建
$ gpg --gen-key
接下来你有这个输出:
gpg (GnuPG) 2.0.14;版权所有 (C) 2009 Free Software Foundation, Inc. 这是免费软件:您可以自由更改和重新分发它。在法律允许的范围内,不提供任何保证。
请选择您想要的钥匙类型:
- (1) RSA 和 RSA(默认)
- (2) DSA 和 Elgamal
- (3) DSA(仅签名)
- (4) RSA(仅符号)
你的选择?RSA 密钥的长度可能在 1024 到 4096 位之间。你想要什么尺寸的钥匙?(2048)
请求的密钥大小为 2048 位
请指定密钥的有效期。
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
密钥有效吗?(0)
密钥根本不会过期这
是正确的吗?(是/否)是
GnuPG needs to construct a user ID to identify your key.
Real name: xxx
Email address: xxx@example.com
Comment: gpg for xxx
You selected this USER-ID:
"xxx(gpg for xxx) <xxx@example.com>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.
can't connect to `/xxx/.gnupg/S.gpg-agent': No such file or directory
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.