gpg:被用户取消

use*_*531 5 security encryption key-authentication gpg

尝试创建将用于托管在我的 Centos7 机器上的 apt 存储库的 GPG 密钥。我创建了一个新用户“apt”,然后尝试创建密钥,但最后,它指出我需要一个密码短语,但随后立即关闭说明被用户取消。不,不是!

从那以后,我成功地重复了这些相同的步骤 root 并作为我的标准用户名,它恰好在轮组中。

两个问题:

  1. 将不同的 gpg 密钥用于不同的用途(例如这个 apt 存储库)是否是个好主意,并且是否应该以 root 身份创建密钥?
  2. 为什么我无法为该用户创建 gpg 密钥?我是否需要先为该用户创建其他密钥?

谢谢

[apt@devserver ~]$ gpg --gen-key
gpg (GnuPG) 2.0.22; Copyright (C) 2013 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

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 keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
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
Key expires at Thu 12 Jul 2018 04:32:05 PM UTC
Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key.

Real name: somename
Email address: example@gmail.com
Comment:
You selected this USER-ID:
    "somename <example@gmail.com>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.

gpg: cancelled by user
gpg: Key generation canceled.
[apt@devserver ~]$
Run Code Online (Sandbox Code Playgroud)

der*_*ert 13

至于“被用户取消”错误:GnuPG 试图确保它直接从终端读取密码,而不是(例如)从标准输入管道读取。为此,它会尝试直接打开 tty。不幸的是,文件权限妨碍了 — tty 设备归您登录的用户所有。所以只有那个用户和 root 可以打开它。GnuPG 似乎错误地报告了错误,说您取消了(实际上它的权限被拒绝了)。

至于您是否应该为存储库设置单独的密钥:是的。有几个原因让我想到:

  • 一个存储库可以由多个人维护。他们都需要访问密钥。您显然不想让他们访问您的个人密钥。
  • 处理新包的软件需要访问密钥。对于许多存储库,这意味着您必须在连接 Internet 的机器上保持密钥可用。这需要比您理想的个人密钥更低的安全级别。
  • 如果您正在自动处理上传,您甚至可能需要存储没有密码短语的密钥。显然降低了安全性。
  • 如果您的个人密钥被泄露,只需撤销它就好了。与存储库密钥的妥协相同。它使撤销受损密钥的成本更低。

使用您的个人密钥对存储库密钥进行签名是很正常的。

至于以 root 身份运行密钥生成:不理想(不要在没有充分理由的情况下以 root 身份运行),但可能不是真正的问题。

  • @Ziffusion我猜想任何给它一个新的tty的东西都会起作用,例如,在“screen”内运行。或者您可以作为登录用户生成密钥,然后复制它们。 (2认同)