From Fedora Project Wiki
m (Update translations)
 
(5 intermediate revisions by 2 users not shown)
Line 15: Line 15:
{{admon/warning|如果您忘记了您的密码短语,那么密钥将会无法使用且使用该密钥加密的数据将会丢失!|}}
{{admon/warning|如果您忘记了您的密码短语,那么密钥将会无法使用且使用该密钥加密的数据将会丢失!|}}


To find your GPG key ID click on the ''My Personal Keys'' tab and look in the ''Key ID'' column next to the newly created key.  In most cases, if you are asked for the key ID, you should prepend "0x" to the key ID, as in "0x6789ABCD".
要查找你的GPG密钥ID,单击“My Personal Keys”选项,然后查看新创建密钥在“Key ID”旁边。 在大多数情况下,如果要求你输入密钥ID,则应在密钥ID前加“0x”,如“0x6789ABCD”。


Now you should [[#BackupGNOME| make a backup]] of your private key.
现在你可以对你的私密[[#BackupGNOME|做一个备份]]


{{Anchor|CreateKDE}}
{{Anchor|CreateKDE}}
Line 25: Line 25:
从主菜单 ''工具 > PIM > KGpg'' 启动 '''KGpg'''。如果您从未使用过,程序将会带您一步步完成创建。
从主菜单 ''工具 > PIM > KGpg'' 启动 '''KGpg'''。如果您从未使用过,程序将会带您一步步完成创建。


A dialog box appears prompting you to create a new key pair.  Enter your name, email address, and an optional comment.  You can also choose an expiration time for your key, as well as the key strength (number of bits) and algorithms.  The next dialog box prompts you for your passphrase.  At this point, your key appears in the main '''KGpg''' window.
它将出现一个对话框,提示你创建新密钥对。 输入您的姓名,电子邮件地址和可选备注信息。 你还可以选择密钥的到期时间,以及密钥强度(位数)和算法。 下一个对话框将提示你输入密码。 此时,你的密钥出现在主窗口中'''KGpg'''


{{admon/warning|If you forget your passphrase, the key cannot be used and any data encrypted using that key will be lost.|}}
{{admon/warning|如果你忘记了密码,则无法使用密钥,并且使用该密钥加密的任何数据都将丢失。|}}


欲寻找您的 GPG 密钥 ID,请将目光转向新创建的密钥旁边的 ''密钥 ID'' 一栏。绝大多数情况下,如果您被询问密钥 ID,您应该输入的是在刚才看到的那一栏的字符串加上 "0x" 的新字符串,比如 "0x6789ABCD"。
欲寻找你的 GPG 密钥 ID,请将目光转向新创建的密钥旁边的 ''密钥 ID'' 一栏。绝大多数情况下,如果你被询问密钥 ID,你应该输入的是在刚才看到的那一栏的字符串加上 "0x" 的新字符串,比如 "0x6789ABCD"。


现在您只需要 [[#备份|备份]] 一下您的私钥即可。
现在你只需要 [[#BackupKDE|备份]] 一下你的私钥即可。


{{Anchor|CreateCLI}}
{{Anchor|CreateCLI}}
Line 44: Line 44:
该命令将会生成一个包含公钥和私钥的密钥对。其他人使用您发布的公钥来验证或解密您的加密信息。将 '''公钥''' 尽可能的发给别人,尤其是那些您需要发送加密信息给他们的人,比如邮件列表。例如 Fedora 文档项目,就会要求所有人员在 [DocsProject/SelfIntroduction|自我介绍]] 里提供自己的公钥。
该命令将会生成一个包含公钥和私钥的密钥对。其他人使用您发布的公钥来验证或解密您的加密信息。将 '''公钥''' 尽可能的发给别人,尤其是那些您需要发送加密信息给他们的人,比如邮件列表。例如 Fedora 文档项目,就会要求所有人员在 [DocsProject/SelfIntroduction|自我介绍]] 里提供自己的公钥。


A series of prompts directs you through the process. Press the '''Enter''' key to assign a default value if desired. The first prompt asks you to select what kind of key you prefer:
一系列提示将指导你完成整个过程。 如果需要,按'''Enter'''键指定默认值。 第一个提示会要求你选择您喜欢的密钥类型:


<pre>
<pre>
Line 55: Line 55:
</pre>
</pre>


绝大多数情况下默认即可。A RSA/RSA key allows you not only to sign communications, but also to encrypt files.
绝大多数情况下默认即可。RSA/RSA 密钥不仅允许你加密通讯,还可以加密文件。


下一步,选择密钥大小:
下一步,选择密钥大小:
Line 66: Line 66:
还是默认的即可。针对绝大多数用户,默认的就是非常强的安全级别。
还是默认的即可。针对绝大多数用户,默认的就是非常强的安全级别。


下一步,选择密钥到期时间。这里建议您选择一个到期时间而不是默认的 ''none.''。If, for example, the email address on the key becomes invalid, an expiration date will remind others to stop using that public key.
下一步,选择密钥到期时间。这里建议你选择一个到期时间而不是默认的 ''none.''。例如,如果密钥上的电子邮件地址无效,则到期时将提醒其他人停止使用该公钥。
 
<pre>
<pre>
Please specify how long the key should be valid.
Please specify how long the key should be valid.
Line 79: Line 78:
</pre>
</pre>


Entering a value of <code>1y</code>, for example, makes the key valid for one year. (You may change this expiration date after the key is generated, if you change your mind.)
例如,输入值<code>1y</code>会使密钥有效期为一年。 (如果你改变主意,可以在生成密钥后更改此日期。)


Before the <code>gpg</code> program asks for signature information, the following prompt appears:
<code>gpg</code>程序要求签名信息之前,会出现以下提示:


<pre>
<pre>
Line 87: Line 86:
</pre>
</pre>


Enter <code>y</code> to finish the process.
输入<code>y</code>完成。


Next, enter your name and email address. ''Remember this process is about authenticating you as a real individual.''  For this reason, include your ''real name''.  Do not use aliases or handles, since these disguise or obfuscate your identity.
接下来,输入你的姓名和电子邮件地址。 “Remember this process is about authenticating you as a real individual.“(请记住,这个过程是会用你个人的真实身份进行验证。)因此,请输入你的“real name”(真实名字)。 不要使用别名或编号,因为这些伪装或混淆了你的身份。


Enter your real email address for your GPG key.  If you choose a bogus email address, it will be more difficult for others to find your public key.  This makes authenticating your communications difficult.  If you are using this GPG key for [[DocsProject/SelfIntroduction| self-introduction]] on a mailing list, for example, enter the email address you use on that list.
输入你的GPG密钥的真实电子邮件地址。 如果你选择虚假的电子邮件地址,则其他人更难找到你的公钥。 这使得验证你的通信变得困难。 如果你使用此GPG密钥进行[[DocsProject/SelfIntroduction| 自我介绍]] ,例如,在邮件列表上输入你使用的电子邮件地址。


Use the comment field to include aliases or other information.  (Some people use different keys for different purposes and identify each key with a comment, such as "Office" or "Open Source Projects.")
使用注释字段存储别名或其他信息。 (有些人使用不同的密钥用于不同的目的,并用注释标识每个密钥,例如“Office”或“Open Source Projects.”(开源项目)。)


At the confirmation prompt, enter the letter '''O''' to continue if all entries are correct, or use the other options to fix any problems.
会有提示确认,如果所有信息都正确,则输入字母'''O'''继续,或使用其它方式来解决问题。


Finally, enter a passphrase for your secret key.  The <code>gpg</code> program asks you to enter your passphrase twice to ensure you made no typing errors.
最后输入密钥的密码。 这<code>gpg</code>程序会要求你输入两次密码,以确保你没有输入错误。


Finally, <code>gpg</code> generates random data to make your key as unique as possible.  Move your mouse, type random keys, or perform other tasks on the system during this step to speed up the process.  Once this step is finished, your keys are complete and ready to use:
最后,<code>gpg</code> 生成随机数据,使你的密钥尽可能唯一。 在此步骤中移动鼠标,键入随机键或在系统上执行其他任务以加快此过程。 完成此操作后,你的密钥已生成并可以使用:


<pre>
<pre>
Line 107: Line 106:
</pre>
</pre>


The key fingerprint is a shorthand "signature" for your key.  It allows you to confirm to others that they have received your actual public key without any tampering.  You do not need to write this fingerprint down.  To display the fingerprint at any time, use this command, substituting your email address:
密钥指纹是密钥的简写“signature”。 它允许你向其他人确认他们已收到你的真实公钥而不进行任何篡改。 你无需记录保存此指纹。 需要查看指纹时,请使用此命令替换你的电子邮件地址:


<pre>
<pre>
Line 113: Line 112:
</pre>
</pre>


Your "GPG key ID" consists of 8 hex digits identifying the public key. In the example above, the GPG key ID is 1B2AFA1C.  In most cases, if you are asked for the key ID, you should prepend "0x" to the key ID, as in "0x1B2AFA1C".
你的"GPG key ID"由8个16进制数字组成,用于标记公钥。 在上面的示例中,GPG密钥ID为1B2AFA1C。 在大多数情况下,如果要求你输入密钥ID,则应在密钥ID前加“0x”,如“0x1B2AFA1C”。


{{admon/warning|If you forget your passphrase, the key cannot be used and any data encrypted using that key will be lost.|}}
{{admon/warning|如果您忘记了密码,则无法使用密钥,并且使用该密钥加密的任何数据都将丢失。|}}


Now you should [[#BackupCLI| make a backup]] of your private key.
现在你应该[[#BackupCLI|备份]]你的私钥。


{{Anchor|Backup}}
{{Anchor|Backup}}
Line 123: Line 122:
== 备份 ==
== 备份 ==


{{admon/important | Make a backup of your private key and put it in a safe location such as a CD, DVD, or USB key stored in a secure container.||}}
{{admon/important | 备份你的私钥并将其放在安全的位置,例如存储在安全位置例如CD,DVD或USB密钥。||}}


{{Anchor|BackupGNOME}}
{{Anchor|BackupGNOME}}
=== 在 GNOME/MATE 桌面环境上备份 ===
=== 在 GNOME/MATE 桌面环境上备份 ===


Right-click your key and select ''Properties''.  Select the ''Details'' tab, and ''Export'', next to the ''Export Complete Key'' label. Select a destination filename and click ''Save''.
右键单击你的密钥,然后选择“Properties(属性)”。 选择“Details(详情)“标签,然后选择“Export Complete Key(导出完成密钥)”标签旁边的“Export(导出)”。 选择目标文件名,然后单击“Save(保存)”。


Store the copy in a secure place, such as a locked container.  Now you are ready to [[#ExportGNOME| make your public key available to others]] .
将副本存储在安全的位置,例如一个锁着的箱子(容器)。 现在你准备[[#ExportGNOME | 让你的公钥可供他人使用]]


{{Anchor|BackupKDE}}
{{Anchor|BackupKDE}}


=== Making a Key Backup Using the KDE Desktop ===
=== 使用KDE桌面进行密钥备份 ===


Right-click your key and select ''Export Secret Key''.  At the confirmation dialog, click ''Export'' to continue, then select a destination filename and click ''Save''.
右键单击你的密钥,然后选择“Export Secret Key(导出密钥)”。 在确认对话框中,单击“Export(导出)”以继续,然后选择目标文件名并单击“Save(保存)”。


Store the copy in a secure place, such as a locked container.  Now you are ready to [[#ExportKDE| make your public key available to others]] .
将副本存储在安全的位置,例如一个锁定的箱子(容器)。 现在你准备[[#ExportKDE | 让你的公钥可供他人使用]]


{{Anchor|BackupCLI}}
{{Anchor|BackupCLI}}
=== Making a Key Backup Using the Command Line ===
=== 用命令行进行密钥备份 ===


Use the following command to make the backup, which you can then copy to a destination of your choice:
使用以下命令进行备份,然后可以将其复制到你选择的目标位置:


<pre>
<pre>
Line 149: Line 148:
</pre>
</pre>


Store the copy in a secure place, such as a locked container.  Now you are ready to [[#ExportCLI| make your public key available to others]] .
将副本存储在安全的位置,例如一个锁定的箱子(容器)。 现在你准备[[#ExportCLI | 让你的公钥可供他人使用]]


{{Anchor|Export}}
{{Anchor|Export}}
== 让您的公钥被公众使用 ==
== 让你的公钥被公众使用 ==


When you make your public key available to others, they can verify communications you sign, or send you encrypted communications if necessary.  This procedure is also known as ''exporting''.
当你向其他人提供公钥时,他们可以验证你加密的信息,或在必要时向你发送加密通信。 此过程也称为“exporting(导出)”。


You should now export your key using [[#ExportGNOME| GNOME]] , [[#ExportKDE| KDE]] , or the [[#ExportCLI| command line]] .  You can also [[#ExportFile| copy your key manually]] to a file if you wish to email it to individuals or groups.
你现在应该使用[[#ExportGNOME| GNOME]][[#ExportKDE | KDE]],或[[#ExportCLI| 命令行]]导出 。 你也可以 [[#ExportFile|手动复制公钥]]到文件中,如果你希望通过电子邮件将公钥发送给个人或群组。


{{Anchor|ExportGNOME}}
{{Anchor|ExportGNOME}}
=== 在 GNOME 桌面环境上导出 ===
=== 在 GNOME 桌面环境上导出 ===


Export the key to a public keyserver where other project members can obtain it. Right-click the key and select ''Sync and Publish Keys...'' (or in the seahorse menu bar click on the ''Remote'' menu and select ''Sync and Publish Keys...''). Click ''Key Servers'', select ''hkp://subkeys.pgp.net:11371'' in the ''Publish Keys To'' combobox, click ''Close'' and then ''Sync''.
将密钥导出到公钥服务器,其他项目成员可以从中获取密钥。 右键单击该键并选择“Sync and Publish Keys...(同步与发布...)”(或在seahorse菜单栏中单击“Remote(远程)”菜单并选择“Sync and Publish Keys...(同步与发布...)”)。 点击''Key Servers'',在''Publish Keys To''组合框中选择“hkp://subkeys.pgp.net:11371”,点击''Close(关闭)''再点击''Sync(同步)''


{{admon/note||If the key can't be synchronized, the traffic may  be blocked by a firewall.  In this case you can publish the key with a different method.  Copy the key by right-clicking the key and selecting ''Copy Public Key''.  Use a web browser to load the page "http://subkeys.pgp.net/", paste (Ctrl+V) the public key in the ''Submit a Key'' textbox and click ''Submit this key to the keyserver!''.  Your public key then becomes available on the public server for others to copy and use.}}
{{admon/note||如果密钥无法同步,则防火墙可能会阻止流量。 在这种情况下,你可以使用其他方法发布密钥。 通过右键单击密钥并选择“Copy Public Key(复制公钥)”来复制密钥。 使用Web浏览器加载页面“http://subkeys.pgp.net/”,粘贴(Ctrl + V)“Submit a Key(提交密钥)”文本框中的公钥,然后单击“Submit this key to the keyserver!(将此密钥提交到密钥服务器)”。 然后,你的公钥将在公共服务器上可供其他人复制和使用。}}


You can now [[#Safeguarding| read more about safeguarding your key]] or use your browser to go back to a previous page.
你现在可以[[#Safeguarding|阅读更多关于保护你的密钥的方法]]或使用你的浏览器返回上一页。


{{Anchor|ExportKDE}}
{{Anchor|ExportKDE}}


=== Exporting a GPG Key Using the KDE Desktop ===
=== 使用KDE桌面导出GPG密钥 ===


After your key has been generated, you can export the key to a public keyserver by right-clicking on the key in the main window, and selecting ''Export Public Keys''.  From there you can export your public key to the clipboard, an ASCII file, to an email, or directly to a key server.  Export your public key to the default key server.
生成密钥后,可以通过右键单击主窗口中的公钥并选择“Export Public Keys(导出公钥)”来将公钥导出到公钥服务器。 从那里,你可以将公钥导出到剪贴板,ASCII文件,电子邮件或直接导出到公钥服务器。 将你的公钥导出到默认公钥服务器。


{{admon/note||If the key can't be synchronized, the traffic may  be blocked by a firewall.  In this case you can publish the key with a different method.  Copy the key by right-clicking the key and selecting ''Copy Public Key''.  Use a web browser to load the page "http://subkeys.pgp.net/", paste (Ctrl+V) the public key in the ''Submit a Key'' textbox and click ''Submit this key to the keyserver!''.  Your public key then becomes available on the public server for others to copy and use.}}
如果公钥无法同步,则可能会被防火墙阻止。 在这种情况下,你可以使用其他方法发布公钥。 通过右键单击密钥并选择“Copy Public Key(复制公钥)”来复制密钥。 使用Web浏览器加载页面“http://subkeys.pgp.net/”,粘贴(Ctrl + V)“Submit a Key(提交密钥)”文本框中的公钥,然后单击“Submit this key to the keyserver!(将此密钥提交到密钥服务器)“。 然后,你的公钥将在公共服务器上可供其他人复制和使用。


You can now [[#Safeguarding| read more about safeguarding your key]] or use your browser to go back to a previous page.
你现在可以[[#Safeguarding|阅读更多关于保护你的密钥的信息]]或使用你的浏览器返回上一页。


{{Anchor|ExportCLI}}
{{Anchor|ExportCLI}}
=== 使用命令行导出 ===
=== 使用命令行导出 ===


Use the following command to send your key to a public keyserver:
使用以下命令将公钥发送到公钥服务器:


<pre>
<pre>
Line 188: Line 187:
For ''KEYNAME'', substitute the key ID of your primary keypair.
For ''KEYNAME'', substitute the key ID of your primary keypair.


You can now [[#Safeguarding| read more about safeguarding your key]] or use your browser to go back to a previous page.
你现在可以[[#Safeguarding|阅读更多关于保护你的密钥的信息]]或使用你的浏览器返回上一页。


=== 手工复制一个公钥 ===
=== 手工复制一个公钥 ===


If you want to give or send a file copy of your key to someone, use this command to write it to an ASCII text file:
如果要向某人提供或发送密钥的文件副本,请使用此命令将其写入ASCII文本文件:


<pre>
<pre>
Line 198: Line 197:
</pre>
</pre>


You can now [[#Safeguarding| read more about safeguarding your key]] or use your browser to go back to a previous page.
你现在可以[[#Safeguarding| 阅读更多关于保护密钥的信息]] 或使用你的浏览器返回上一页。


{{Anchor|Safeguarding}}
{{Anchor|Safeguarding}}
Line 204: Line 203:
== 保护您的私钥 ==
== 保护您的私钥 ==


Treat your secret key as you would any very important document or physical key.  (Some people always keep their secret key on their person, either on magnetic or flash media.)  If you lose your secret key, you will be unable to sign communications, or to open encrypted communications that were sent to you.
像对待任何非常重要的文档或重要的钥匙一样对待你的密钥。 (有些人总是将他们的密钥放在他们的身上,无论是在磁性还是闪存上。)如果你丢失了密钥,你将无法进行通信或打开发送给你的加密信息。


{{admon/warning | Always keep your passphrase secret! | Even if your secret key is accessed by someone else, they will be unable to use it without your passphrase.  Do not choose a passphrase that someone else might easily guess.  Do not use single words (in any language), strings of numbers such as your telephone number or an official document number, or biographical data about yourself or your family for a passphrase.  The most secure passphrases are ''very long'' and contain a mixture of uppercase and lowercase letters, numbers, digits, and symbols.  Choose a passphrase that you will be able to remember, however, since writing this passphrase down anywhere makes it immediately less secure.}}
{{admon/warning | 始终保护好密钥密码!| 即使你的密钥被其他人访问,如果没有你的密码,他们也无法使用它。不要选择别人可能容易猜到的密码。请勿使用单个单词(任何语言),数字串(如电话号码或官方文档编号)或有关你自己或家人的信息数据作为密码。最安全的密码短语“非常长”,包含大写和小写字母,数字,数字和符号的混合。然而,选择一个能够记住的密码短语,因为在任何地方写下这个密码短语会立即降低其安全性。}}


{{Anchor|Revocation}}
{{Anchor|Revocation}}
== GPG Key Revocation ==


When you revoke a key, you withdraw it from public use.  ''You should only have to do this if it is compromised or lost, or you forget the passphrase.''
== 撤销GPG密钥==
 
当你撤销你的密钥权限时,你需要从所有使用它的位置移处。“只有在它被泄露或丢失,或者你忘记了密码时,你需要这样做。”


=== Generating a Revocation Certificate ===
=== 生成撤销证书 ===


When you create the key pair you should also create a key revocation certificate.  If you later issue the revocation certificate, it notifies others that the public key is not to be used.  Users may still use a revoked public key to verify old signatures, but not encrypt messages.  As long as you still have access to the private key, messages received previously may still be decrypted.  If you forget the passphrase, you will not be able to decrypt messages encrypted to that key.
当你创建了一对密钥时,还应创建密钥的吊销证书。如果你稍后颁发吊销证书,它会通知其他人公钥不可用。用户仍然可以使用撤销的公钥来验证旧签名,但不会加密消息。只要你仍然可以访问私钥,以前收到的消息仍然可以解密。如果你忘记了密码,你将无法解密此加密信息。


<pre>
<pre>
Line 221: Line 221:
</pre>
</pre>


If you do not use the <code>--output</code> flag, the certificate will print to standard output.
如果不使用<code>--output</code> 选项, 证书会正常输出。


For ''KEYNAME'', substitute either the key ID of your primary keypair or any part of a user ID that identifies your keypair.  Once you create the certificate  (the <code>revoke.asc</code> file), you should protect it.  If it is published by accident or through the malicious actions of others, the public key will become unusable.  It is a good idea to write the revocation certificate to secure removable media or print out a hard copy for secure storage to maintain secrecy.
For ''KEYNAME'', substitute either the key ID of your primary keypair or any part of a user ID that identifies your keypair.  Once you create the certificate  (the <code>revoke.asc</code> file), you should protect it.  If it is published by accident or through the malicious actions of others, the public key will become unusable.  It is a good idea to write the revocation certificate to secure removable media or print out a hard copy for secure storage to maintain secrecy.


=== Revoking a key ===
=== 撤销密钥 ===


<pre>
<pre>
Line 231: Line 231:
</pre>
</pre>


Once you locally revoke the key, you should send the revoked certificate to a keyserver, regardless of whether the key was originally issued in this way.  Distribution through a server helps other users to quickly become aware the key has been compromised.
一旦你在本地撤销密钥,你应该将撤销的证书发送到密钥服务器,无论密钥是否最初是以哪种方式发出的。 通过服务器分发有助于其他用户快速意识到密钥已被泄露。


Export to a keyserver with the following command:
使用以下命令导出到密钥服务器:


<pre>
<pre>
Line 243: Line 243:
访问 [https://fedoraproject.org/wiki/Using_GPG GPG 使用] 页面了解如何使用您的 GPG 密钥。
访问 [https://fedoraproject.org/wiki/Using_GPG GPG 使用] 页面了解如何使用您的 GPG 密钥。


[[Category:Documentation]]
[[Category:Informal_Documentation]]
[[Category:Encryption]]

Latest revision as of 09:08, 22 February 2019

本页详细讲述了如何使用 Fedora 自带的工具创建 GPG 密钥,以及作为一名 Fedora 贡献人员如何管理您的密钥。

创建 GPG 密钥

在 GNOME/MATE 桌面环境上创建

首先请安装 Seahorse 工具,该工具将会使得您管理 GPG 密钥更方便。从主菜单选择 应用程序 > 添加/删除程序。选择搜索标签并输入 seahorse。勾上 seahorse 软件包旁边的复选框并点击 应用 即可完成安装。您也可以使用命令行安装安装 Seahorsesu -c "yum install seahorse".

欲创建一个密钥,打开 应用程序 > Accessories 菜单并选择 Passwords and Encryption Keys,随后会启动 Seahorse

文件 菜单选择 新建... 然后选择 PGP Key 并点击 继续。输入您的全名,邮件地址和可选的一些个人描述(e.g.: John C. Smith, jsmith@example.com, The Man)。点击 创建。一个对话框会显示并询问该密钥的密码短语。输入完毕后点击 OK 即可完成创建。

Warning.png
如果您忘记了您的密码短语,那么密钥将会无法使用且使用该密钥加密的数据将会丢失!

要查找你的GPG密钥ID,单击“My Personal Keys”选项,然后查看新创建密钥在“Key ID”旁边。 在大多数情况下,如果要求你输入密钥ID,则应在密钥ID前加“0x”,如“0x6789ABCD”。

现在你可以对你的私密做一个备份

在 KDE 桌面环境上创建

从主菜单 工具 > PIM > KGpg 启动 KGpg。如果您从未使用过,程序将会带您一步步完成创建。

它将出现一个对话框,提示你创建新密钥对。 输入您的姓名,电子邮件地址和可选备注信息。 你还可以选择密钥的到期时间,以及密钥强度(位数)和算法。 下一个对话框将提示你输入密码。 此时,你的密钥出现在主窗口中KGpg

Warning.png
如果你忘记了密码,则无法使用密钥,并且使用该密钥加密的任何数据都将丢失。

欲寻找你的 GPG 密钥 ID,请将目光转向新创建的密钥旁边的 密钥 ID 一栏。绝大多数情况下,如果你被询问密钥 ID,你应该输入的是在刚才看到的那一栏的字符串加上 "0x" 的新字符串,比如 "0x6789ABCD"。

现在你只需要 备份 一下你的私钥即可。

使用命令行创建

使用下列命令:

gpg --gen-key

该命令将会生成一个包含公钥和私钥的密钥对。其他人使用您发布的公钥来验证或解密您的加密信息。将 公钥 尽可能的发给别人,尤其是那些您需要发送加密信息给他们的人,比如邮件列表。例如 Fedora 文档项目,就会要求所有人员在 [DocsProject/SelfIntroduction|自我介绍]] 里提供自己的公钥。

一系列提示将指导你完成整个过程。 如果需要,按Enter键指定默认值。 第一个提示会要求你选择您喜欢的密钥类型:

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 

绝大多数情况下默认即可。RSA/RSA 密钥不仅允许你加密通讯,还可以加密文件。

下一步,选择密钥大小:

RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 

还是默认的即可。针对绝大多数用户,默认的就是非常强的安全级别。

下一步,选择密钥到期时间。这里建议你选择一个到期时间而不是默认的 none.。例如,如果密钥上的电子邮件地址无效,则到期时将提醒其他人停止使用该公钥。

Please specify how long the key should be valid.
         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
Key is valid for? (0) 

例如,输入值1y会使密钥有效期为一年。 (如果你改变主意,可以在生成密钥后更改此日期。)

gpg程序要求签名信息之前,会出现以下提示:

Is this correct (y/n)?

输入y完成。

接下来,输入你的姓名和电子邮件地址。 “Remember this process is about authenticating you as a real individual.“(请记住,这个过程是会用你个人的真实身份进行验证。)因此,请输入你的“real name”(真实名字)。 不要使用别名或编号,因为这些伪装或混淆了你的身份。

输入你的GPG密钥的真实电子邮件地址。 如果你选择虚假的电子邮件地址,则其他人更难找到你的公钥。 这使得验证你的通信变得困难。 如果你使用此GPG密钥进行 自我介绍 ,例如,在邮件列表上输入你使用的电子邮件地址。

使用注释字段存储别名或其他信息。 (有些人使用不同的密钥用于不同的目的,并用注释标识每个密钥,例如“Office”或“Open Source Projects.”(开源项目)。)

会有提示确认,如果所有信息都正确,则输入字母O继续,或使用其它方式来解决问题。

最后输入密钥的密码。 这gpg程序会要求你输入两次密码,以确保你没有输入错误。

最后,gpg 生成随机数据,使你的密钥尽可能唯一。 在此步骤中移动鼠标,键入随机键或在系统上执行其他任务以加快此过程。 完成此操作后,你的密钥已生成并可以使用:

pub  1024D/1B2AFA1C 2005-03-31 John Q. Doe (Fedora Docs Project) <jqdoe@example.com>
Key fingerprint = 117C FE83 22EA B843 3E86  6486 4320 545E 1B2A FA1C
sub  1024g/CEA4B22E 2005-03-31 [expires: 2006-03-31] 

密钥指纹是密钥的简写“signature”。 它允许你向其他人确认他们已收到你的真实公钥而不进行任何篡改。 你无需记录保存此指纹。 需要查看指纹时,请使用此命令替换你的电子邮件地址:

gpg --fingerprint jqdoe@example.com

你的"GPG key ID"由8个16进制数字组成,用于标记公钥。 在上面的示例中,GPG密钥ID为1B2AFA1C。 在大多数情况下,如果要求你输入密钥ID,则应在密钥ID前加“0x”,如“0x1B2AFA1C”。

Warning.png
如果您忘记了密码,则无法使用密钥,并且使用该密钥加密的任何数据都将丢失。

现在你应该备份你的私钥。

备份

Important.png
备份你的私钥并将其放在安全的位置,例如存储在安全位置例如CD,DVD或USB密钥。

在 GNOME/MATE 桌面环境上备份

右键单击你的密钥,然后选择“Properties(属性)”。 选择“Details(详情)“标签,然后选择“Export Complete Key(导出完成密钥)”标签旁边的“Export(导出)”。 选择目标文件名,然后单击“Save(保存)”。

将副本存储在安全的位置,例如一个锁着的箱子(容器)。 现在你准备 让你的公钥可供他人使用

使用KDE桌面进行密钥备份

右键单击你的密钥,然后选择“Export Secret Key(导出密钥)”。 在确认对话框中,单击“Export(导出)”以继续,然后选择目标文件名并单击“Save(保存)”。

将副本存储在安全的位置,例如一个锁定的箱子(容器)。 现在你准备 让你的公钥可供他人使用

用命令行进行密钥备份

使用以下命令进行备份,然后可以将其复制到你选择的目标位置:

gpg --export-secret-keys --armor jqdoe@example.com > jqdoe-privkey.asc

将副本存储在安全的位置,例如一个锁定的箱子(容器)。 现在你准备 让你的公钥可供他人使用

让你的公钥被公众使用

当你向其他人提供公钥时,他们可以验证你加密的信息,或在必要时向你发送加密通信。 此过程也称为“exporting(导出)”。

你现在应该使用 GNOME KDE,或 命令行导出 。 你也可以 手动复制公钥到文件中,如果你希望通过电子邮件将公钥发送给个人或群组。

在 GNOME 桌面环境上导出

将密钥导出到公钥服务器,其他项目成员可以从中获取密钥。 右键单击该键并选择“Sync and Publish Keys...(同步与发布...)”(或在seahorse菜单栏中单击“Remote(远程)”菜单并选择“Sync and Publish Keys...(同步与发布...)”)。 点击Key Servers,在Publish Keys To组合框中选择“hkp://subkeys.pgp.net:11371”,点击Close(关闭)再点击Sync(同步)

Note.png
如果密钥无法同步,则防火墙可能会阻止流量。 在这种情况下,你可以使用其他方法发布密钥。 通过右键单击密钥并选择“Copy Public Key(复制公钥)”来复制密钥。 使用Web浏览器加载页面“http://subkeys.pgp.net/”,粘贴(Ctrl + V)“Submit a Key(提交密钥)”文本框中的公钥,然后单击“Submit this key to the keyserver!(将此密钥提交到密钥服务器)”。 然后,你的公钥将在公共服务器上可供其他人复制和使用。

你现在可以阅读更多关于保护你的密钥的方法或使用你的浏览器返回上一页。

使用KDE桌面导出GPG密钥

生成密钥后,可以通过右键单击主窗口中的公钥并选择“Export Public Keys(导出公钥)”来将公钥导出到公钥服务器。 从那里,你可以将公钥导出到剪贴板,ASCII文件,电子邮件或直接导出到公钥服务器。 将你的公钥导出到默认公钥服务器。

如果公钥无法同步,则可能会被防火墙阻止。 在这种情况下,你可以使用其他方法发布公钥。 通过右键单击密钥并选择“Copy Public Key(复制公钥)”来复制密钥。 使用Web浏览器加载页面“http://subkeys.pgp.net/”,粘贴(Ctrl + V)“Submit a Key(提交密钥)”文本框中的公钥,然后单击“Submit this key to the keyserver!(将此密钥提交到密钥服务器)“。 然后,你的公钥将在公共服务器上可供其他人复制和使用。

你现在可以阅读更多关于保护你的密钥的信息或使用你的浏览器返回上一页。

使用命令行导出

使用以下命令将公钥发送到公钥服务器:

gpg --keyserver hkp://subkeys.pgp.net --send-key KEYNAME

For KEYNAME, substitute the key ID of your primary keypair.

你现在可以阅读更多关于保护你的密钥的信息或使用你的浏览器返回上一页。

手工复制一个公钥

如果要向某人提供或发送密钥的文件副本,请使用此命令将其写入ASCII文本文件:

gpg --export --armor jqdoe@example.com > jqdoe-pubkey.asc

你现在可以 阅读更多关于保护密钥的信息 或使用你的浏览器返回上一页。

保护您的私钥

像对待任何非常重要的文档或重要的钥匙一样对待你的密钥。 (有些人总是将他们的密钥放在他们的身上,无论是在磁性还是闪存上。)如果你丢失了密钥,你将无法进行通信或打开发送给你的加密信息。

Warning.png
始终保护好密钥密码!
即使你的密钥被其他人访问,如果没有你的密码,他们也无法使用它。不要选择别人可能容易猜到的密码。请勿使用单个单词(任何语言),数字串(如电话号码或官方文档编号)或有关你自己或家人的信息数据作为密码。最安全的密码短语“非常长”,包含大写和小写字母,数字,数字和符号的混合。然而,选择一个能够记住的密码短语,因为在任何地方写下这个密码短语会立即降低其安全性。

撤销GPG密钥

当你撤销你的密钥权限时,你需要从所有使用它的位置移处。“只有在它被泄露或丢失,或者你忘记了密码时,你需要这样做。”

生成撤销证书

当你创建了一对密钥时,还应创建密钥的吊销证书。如果你稍后颁发吊销证书,它会通知其他人公钥不可用。用户仍然可以使用撤销的公钥来验证旧签名,但不会加密消息。只要你仍然可以访问私钥,以前收到的消息仍然可以解密。如果你忘记了密码,你将无法解密此加密信息。

gpg --output revoke.asc --gen-revoke KEYNAME

如果不使用--output 选项, 证书会正常输出。

For KEYNAME, substitute either the key ID of your primary keypair or any part of a user ID that identifies your keypair. Once you create the certificate (the revoke.asc file), you should protect it. If it is published by accident or through the malicious actions of others, the public key will become unusable. It is a good idea to write the revocation certificate to secure removable media or print out a hard copy for secure storage to maintain secrecy.

撤销密钥

gpg --import revoke.asc

一旦你在本地撤销密钥,你应该将撤销的证书发送到密钥服务器,无论密钥是否最初是以哪种方式发出的。 通过服务器分发有助于其他用户快速意识到密钥已被泄露。

使用以下命令导出到密钥服务器:

gpg --keyserver subkeys.pgp.net --send KEYNAME

For KEYNAME, substitute either the key ID of your primary keypair or any part of a user ID that identifies your keypair.

访问 GPG 使用 页面了解如何使用您的 GPG 密钥。