想搞个gpg秘钥在github上验证用,

创建密钥需要足够多的/dev/random内容,所以可能卡住需要瞎动动鼠标键盘,

#!/bin/sh
name="AoEiuV020"
email="[email protected]"
cat > .gpgbatch <<EOF
Key-Type: 1
Key-Length: 4096
Subkey-Type: 1
Subkey-Length: 4096
Name-Real: $name
Name-Email: $email
Expire-Date: 0
%no-ask-passphrase
%no-protection
EOF
gpg --default-new-key-algo rsa4096 --batch --gen-key .gpgbatch
rm .gpgbatch
git config --global user.name "$name"
git config --global user.email "$email"
git config --global commit.gpgsign true

然后普通commit就可以使用这个密钥签名,

给旧commit重新签名,会改变hash,等于重新commit,

git rebase --exec 'git commit --amend --no-edit -n -S' --root

检查commit的签名,

git show --show-signature HEAD | head

导出公钥给github,

gpg --armor --export  [email protected]

导出秘钥,

gpg --export-secret-keys [email protected] > gpg.key

导入密钥,卡住了,应该也是要/dev/random,不应该啊,,,第二天再运行就正常,莫名,

gpg --import gpg.key

gpg过期