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

标签 windows git gnupg gpg-agent

我正在尝试开始签署 Git 提交。我使用 keybase.io 设置了一个 GPG key ,并将其同步到我的本地计算机和我的 Git 服务器上。现在,我正在尝试解决在每次提交 时输入 key 密码的问题。

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

我看到手册页讨论了如何在 Bash session 中启动 gpg-agent,但我不确定如何将其转换为 Windows 并让它在 cmd.exe 和 PowerShell 中工作。

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

最佳答案

  1. 您可以使用 gpgconf --launch gpg-agent 让 gpg-agent 在 Windows 后台运行。

  2. 为了让 gpg-agent 在我登录时自动运行,我在任务计划程序中添加了一个任务:

gpg-agent-autostart

  1. 要扩展密码的到期时间,请将这些行添加到 gpg-agent.conf:

    default-cache-ttl 34560000
    
    max-cache-ttl 34560000
    

我试过把号码设置成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

gpg-agent.conf 在 homedir 中

关于windows - 如何在 Windows 上安装和使用 gpg-agent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50332885/

相关文章:

windows - 如何在IFileDialog中更改Places的图标和文本(“Application Links”)?

git - 如何在 docker 中使用 keybase 的 git?

git - 如何解决 Git 错误 : "fatal: BUG: get_tempfile_fd() called for inactive object"

python - 使用 python-gnupg 获取 "OSError: Unable to run gpg () - it may not be available."错误

windows - 使用 Gpg4win 命令行使用公钥批量加密

Gradle signArchives 无法读取 Secret Key

c# - 如何以编程方式获取/设置(Windows 程序的)可视化组件的数据?

c++ - 将 PEM 编码的 X.509 证书加载到 Windows CryptoAPI

windows - Visual Studio 中的 Windows 内核调试器如何工作?

delphi - 是否有用于 Delphi IDE 的 git 插件?