如果你没有GPG Key,你应该先生成一个:
1 | gpg --full-generate-key |
现在,你可以导出签名:
1 | gpg --list-secret-keys --keyid-format LONG |
把pubkey.txt
複製到你的Github https://github.com/settings/keys
设置Git 相关:
1 | git config --global user.signingkey your_key |
设置Git自动输入密码:
1 | echo 'https://{username}:{password}@{gitserver}' >>~/.git-credentials |
导出备份:
1 | gpg2 --export-secret-keys > gpg-sec-keys.db |
导入(导入私钥时会自动导入公钥):
1 | gpg2 --import gpg-sec-keys.db |
注意:
有时需要写环境变量
1 | error: gpg failed to sign the data |
此时你需要
1 | echo export GPG_TTY=$(tty) >> ~/.bashrc |