Ant*_*ean 6 windows git gnupg gpg-agent
我正在尝试开始签署Git提交.我使用keybase.io设置了一个GPG密钥,并将其同步到我的本地计算机和我的Git服务器上.现在,我正在尝试解决在每次提交时键入密钥密码的问题.
PS> git commit -m "testing" --allow-empty
You need a passphrase to unlock the secret key for
user: "keybase.io/anthonymastrean <anthonymastrean@keybase.io>"
2048-bit RSA key, ID AD9184C0, created 2015-04-14 (main key ID 293FEB8B)
Enter passphrase:
Run Code Online (Sandbox Code Playgroud)
据我了解,我需要安装gpg-agent之类的东西.我在Windows 10 Pro 1803上,所以我在看Gpg4win(由GitHub和其他人推荐).我通过Chocolatey安装它,所以我有完整的默认安装.
但是,我无法弄清楚如何让gpg-agent开始缓存我的密码.我每次提交时都会被提示.
gpg-agent表示正在运行
PS> gpg-agent
gpg-agent[4644]: gpg-agent running and available
Run Code Online (Sandbox Code Playgroud)
我有这个gpg-connect-agent的东西,但我不知道该怎么做.
PS> gpg-connect-agent.exe
> help
# NOP
# CANCEL
# OPTION
# BYE
# AUTH
# RESET
# END
# HELP
# GETEVENTCOUNTER
# ISTRUSTED <hexstring_with_fingerprint>
# HAVEKEY <hexstrings_with_keygrips>
# KEYINFO [--[ssh-]list] [--data] [--ssh-fpr] [--with-ssh] <keygrip>
# SIGKEY <hexstring_with_keygrip>
# SETKEY
# SETKEYDESC plus_percent_escaped_string
# SETHASH (--hash=<name>)|(<algonumber>) <hexstring>
# PKSIGN [<options>] [<cache_nonce>]
# PKDECRYPT [<options>]
# GENKEY [--no-protection] [--preset] [--inq-passwd]
# READKEY <hexstring_with_keygrip>
# GET_PASSPHRASE [--data] [--check] [--no-ask] [--repeat[=N]]
# PRESET_PASSPHRASE [--inquire] <string_or_keygrip> <timeout> [<hexstring>]
# CLEAR_PASSPHRASE [--mode=normal] <cache_id>
# GET_CONFIRMATION <description>
# LISTTRUSTED
# MARKTRUSTED <hexstring_with_fingerprint> <flag> <display_name>
# LEARN [--send] [--sendinfo] [--force]
# PASSWD [--cache-nonce=<c>] [--passwd-nonce=<s>] [--preset]
# INPUT
# OUTPUT
# SCD <commands to pass to the scdaemon>
# KEYWRAP_KEY [--clear] <mode>
# IMPORT_KEY [--unattended] [--force] [<cache_nonce>]
# EXPORT_KEY [--cache-nonce=<nonce>] [--openpgp] <hexstring_with_keygrip>
# DELETE_KEY [--force|--stub-only] <hexstring_with_keygrip>
# GETVAL <key>
# PUTVAL <key> [<percent_escaped_value>]
# UPDATESTARTUPTTY
# KILLAGENT
# RELOADAGENT
# GETINFO <what>
# KEYTOCARD [--force] <hexstring_with_keygrip> <serialno> <id> <timestamp>
OK
Run Code Online (Sandbox Code Playgroud)
我看到man页面讨论了如何在Bash会话中启动gpg-agent,但我不确定如何将其转换为Windows并让它在cmd.exe和PowerShell中运行.
Tao*_*Zhu 22
您可以使用gpgconf --launch gpg-agentgpg-agent 在 Windows 的后台运行。
为了让 gpg-agent 在我登录时自动运行,我在 Task Scheduler 中添加了一个任务:
要扩展密码的有效期,请将这些行添加到 gpg-agent.conf:
default-cache-ttl 34560000
max-cache-ttl 34560000
Run Code Online (Sandbox Code Playgroud)我试图将数字设置为 999999999,但它根本不起作用
您可以使用以下命令找到 gpg-agent.conf 的位置:
$ gpgconf.exe --list-dirs
sysconfdir:C%3a\ProgramData\GNU\etc\gnupg
bindir:C%3a\Program Files (x86)\GnuPG\bin
libexecdir:C%3a\Program Files (x86)\GnuPG\bin
libdir:C%3a\Program Files (x86)\GnuPG\lib\gnupg
datadir:C%3a\Program Files (x86)\GnuPG\share\gnupg
localedir:C%3a\Program Files (x86)\GnuPG\share\locale
socketdir:C%3a\Users\Jerry\AppData\Roaming\gnupg
dirmngr-socket:C%3a\Users\Jerry\AppData\Roaming\gnupg\S.dirmngr
agent-ssh-socket:C%3a\Users\Jerry\AppData\Roaming\gnupg\S.gpg-agent.ssh
agent-extra-socket:C%3a\Users\Jerry\AppData\Roaming\gnupg\S.gpg-agent.extra
agent-browser-socket:C%3a\Users\Jerry\AppData\Roaming\gnupg\S.gpg-agent.browser
agent-socket:C%3a\Users\Jerry\AppData\Roaming\gnupg\S.gpg-agent
homedir:C%3a\Users\Jerry\AppData\Roaming\gnupg
Run Code Online (Sandbox Code Playgroud)
gpg-agent.conf 在 homedir
除了陶朱的回答之外,您还可以在Gpg4win附带的GUI 密钥管理器Kleopatra
中指定密码(PIN)过期寿命,而无需配置文件:
在“开始”菜单中找到它并运行。
转到菜单:设置-配置 Kleopatra...

切换到GnuPG System选项卡,然后选择Private Keys选项卡,
将两个设置的默认值更改为您的值Expire cached PINs after N seconds,Set maximum PIN cache lifetime to N seconds我这样设置:

大值可以让您避免在一天中每次 git 提交时频繁且烦人地输入 GPG 密钥的密码(直到下次 Windows 重新启动或指定时间到期)
不幸的是,我还没有找到一种方法来保留会话(重新启动)之间的密码。
我需要通知git我安装的gpg程序,它本身知道它应该使用的gpg-agent.
PS> git config --global gpg.program $(Resolve-Path (Get-Command gpg | Select-Object -Expand Source) | Select-Object -Expand Path)
Run Code Online (Sandbox Code Playgroud)
设置此配置后,弹出Gpg4win的"PIN Entry"对话框!
我可能会遗漏一些自动启动gpg-agent或了解会话生命周期的内容,但我会回过头来了解更多细节.
| 归档时间: |
|
| 查看次数: |
3821 次 |
| 最近记录: |