Gpg

如何使用 gpg 更新過期的加密子密鑰

  • January 3, 2022

我更新了我的 gpg 密鑰對,但我仍然收到來自 gpg 的以下錯誤。

gpg: WARNING: Your encryption subkey expires soon.
gpg: You may want to change its expiration date too.

如何更新子密鑰?

列出你的鑰匙。


$ gpg --list-keys
...
-------------------------------
pub   rsa2048 2019-09-07 [SC] [expires: 2020-11-15]
     AF4RGH94ADC84
uid           [ultimate] Jill Doe (CX) <jilldoe@mail.com>
sub   rsa2048 2019-09-07 [E] [expired: 2019-09-09]

pub   rsa2048 2019-12-13 [SC] [expires: 2020-11-15]
     7DAA371777412
uid           [ultimate] Jill Doe <jilldoe@mail.com>
-------------------------------
...

我們要編輯密鑰 AF4RGH94ADC84。子項是列表中第二個被命名的子項ssb


$ gpg --edit-key AF4RGH94ADC84

gpg> list

sec  rsa2048/AF4RGH94ADC84
    created: 2019-09-07  expires: 2020-11-15  usage: SC
    trust: ultimate      validity: ultimate
ssb  rsa2048/56ABDJFDKFN
    created: 2019-09-07  expired: 2019-09-09  usage: E
[ultimate] (1). Jill Doe (CX) <jilldoe@mail.com>

所以我們要編輯第一個子鍵(ssb)

ssb  rsa2048/56ABDJFDKFN
    created: 2019-09-07  expired: 2019-09-09  usage: E
[ultimate] (1). Jill Doe (CX) <jilldoe@mail.com>

當您選擇鍵 (1) 時,您應該會看到它旁邊的 *,例如ssb*。然後你可以設置過期時間然後保存。

gpg> key 1

sec  rsa2048/AF4RGH94ADC84
    created: 2019-09-07  expires: 2020-11-15  usage: SC
    trust: ultimate      validity: ultimate
ssb*  rsa2048/56ABDJFDKFN
    created: 2019-09-07  expired: 2019-09-09  usage: E
[ultimate] (1). Jill Doe (CX) <jilldoe@mail.com>

gpg> expire
...

Changing expiration time for a subkey.
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) 2y
Key expires at Wed 9 Sep 16:20:33 2021 GMT
Is this correct? (y/N) y

sec  rsa2048/AF4RGH94ADC84
    created: 2019-09-07  expires: 2020-11-15  usage: SC
    trust: ultimate      validity: ultimate
ssb*  rsa2048/56ABDJFDKFN
    created: 2019-09-07  expires: 2021-09-09  usage: E
[ultimate] (1). Jill Doe (CX) <jilldoe@mail.com>
...

gpg> save

退出前不要忘記保存更改!

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