PGP 密钥常用命令记录

本文记录了在使用 gpg 管理 PGP 密钥时的一些常用命令.

查看本地公钥:

gpg -k --keyid-format long

验证私钥密码:

gpg --export-secret-keys -a your_uid > /dev/null && echo OK

发布你的公钥到 key server:

gpg --keyserver keys.openpgp.org --send-keys <key_id>

导出公钥/私钥:

Integrate with git

添加如下代码到 ~/.zshrc:

export GPG_TTY=$(tty)

设置 ~/.gitconfig:

[user]
    signingkey = XXXXXXXXXX
[commit]
    gpgsign = true

Integrate with ssh

在远程主机使用本地的 PGP 密钥: https://wiki.gnupg.org/AgentForwarding

参考