加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

如何在Windows上安装和使用gpg-agent?

发布时间:2020-12-14 04:00:52 所属栏目:Windows 来源:网络整理
导读:我正在尝试开始签署 Git提交.我使用keybase.io设置了一个GPG密钥,并将其同步到我的本地计算机和我的Git服务器上.现在,我正在尝试解决在每次提交时键入密钥密码的问题. PS git commit -m "testing" --allow-emptyYou need a passphrase to unlock the secret
我正在尝试开始签署 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:

据我了解,我需要安装gpg-agent之类的东西.我在Windows 10 Pro 1803上,所以我在看Gpg4win(由GitHub和其他人推荐).我是通过Chocolatey安装的,所以我有完整的默认安装.

但是,我无法弄清楚如何让gpg-agent开始缓存我的密码.我每次提交时都会被提示.

gpg-agent表示正在运行

PS> gpg-agent
gpg-agent[4644]: gpg-agent running and available

我有这个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

我看到man页面讨论了如何在Bash会话中启动gpg-agent,但我不确定如何将其转换为Windows并让它在cmd.exe和PowerShell中运行.

https://linux.die.net/man/1/gpg-agent

解决方法

我需要通知git我已安装的gpg程序,它本身知道它应该使用的gpg-agent.

PS> git config --global gpg.program $(Resolve-Path (Get-Command gpg | Select-Object -Expand Source) | Select-Object -Expand Path)

设置此配置后,弹出Gpg4win的“PIN Entry”对话框!

enter image description here

我可能会遗漏一些自动启动gpg-agent或了解会话生命周期的内容,但我会回过头来了解更多细节.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读