问题描述
该主题上已有一个更通用的主题,在以下情况下记住GPG密码对git commits签名,但那里的答案对我不起作用.我的环境是:
There is already a more generic thread on the topic, Remember GPG password when signing git commits, but the answer there doesn't work for me. My environment is:
- Mac([email protected])
- Bash(macOS随附的默认设置)
- Git v2.27.0
- GnuPG v2.2.20(libgcrypt 1.8.5)
我通过Homebrew安装了GnuPG,并将以下设置写入了~/.gnupg/gpg-agent.conf
文件:
I installed GnuPG via Homebrew and wrote the following settings into the ~/.gnupg/gpg-agent.conf
file:
default-cache-ttl 1209600 # 14 days
max-cache-ttl 31536000 # 1 year
但是未应用缓存. git commit
之后每隔十分钟左右,gpg会提示我再次输入密码.
But the cache isn't applied. Every ten minutes or so after I do a git commit
, gpg prompts me to input the password again.
这是我的全局.gitignore
文件:
[commit]
gpgSign = true
我想念什么?
推荐答案
在我的个人设置中,我已将签名密钥添加到用户部分.
In my personal setup I have added the signingkey to the user section.
[user]
name = "Marco Franssen"
email = "[email protected]"
signingkey = 63B0C3B53E26....
[commit]
gpgSign = true
此外,我在oh-my-zsh中具有以下插件. (~/.zshrc
)
Furthermore I have the following plugins in oh-my-zsh. (~/.zshrc
)
plugins=(git keychain gpg-agent)
zstyle :omz:plugins:keychain agents ssh,gpg
zstyle :omz:plugins:keychain identities id_rsa 63B0C3B53E2....
此插件为我的ssh和gpg密钥启动一个代理.
This plugin boots an agent for my ssh and gpg keys.
我还添加了以下文件
$ cat ~/.gnupg/gpg-agent.conf
default-cache-ttl 3600
对于Bash,您可以将以下内容添加到~/.bashrc
.
For Bash you might add the following to your ~/.bashrc
.
https://github .com/ohmyzsh/ohmyzsh/blob/master/plugins/gpg-agent/gpg-agent.plugin.zsh
这篇关于在Mac上为Git签名缓存GPG密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!