Gpg

GPG 密鑰已複製,無法正常工作

  • July 7, 2015

我已將我的 GPG 密鑰從一台伺服器複製到另一台伺服器,在第一台伺服器上一切正常,在新伺服器上我得到以下資訊:(我已經包含了 list-keys 和 list-secret-keys 的輸出

[www@localhost data]$ gpg escs_hr_feed.pgp

You need a passphrase to unlock the secret key for
user: "Encrypt <encrypt@email.com>"
2048-bit RSA key, ID 8E7BFE3A, created 2015-06-24 (main key ID B943D3E2)

gpg: cancelled by user
gpg: encrypted with 2048-bit RSA key, ID 8E7BFE3A, created 2015-06-24
     "Encrypt <encrypt@email.com>"
gpg: public key decryption failed: General error
gpg: decryption failed: No secret key
[www@localhost data]$ gpg --list-keys
/home/www/.gnupg/pubring.gpg
----------------------------
pub   2048R/B943D3E2 2015-06-24
uid                  Encrypt <encrypt@email.com>
uid                  Master <master@email.com>
sub   2048R/8E7BFE3A 2015-06-24
sub   2048R/6E704692 2015-06-24

[www@localhost data]$ gpg --list-secret-keys
/home/www/.gnupg/secring.gpg
----------------------------
sec   2048R/B943D3E2 2015-06-24
uid                  Master <master@email.com>
uid                  Encrypt <encrypt@email.com>
ssb   2048R/8E7BFE3A 2015-06-24
ssb   2048R/6E704692 2015-06-24

所以問題原來是如果你sudo su -是使用者,你不能使用gpg,你需要直接以使用者身份登錄。

(至少在我公司的伺服器設置上)

引用自:https://unix.stackexchange.com/questions/214354