Windows
此处介绍的方法需要 gpg 2.4.0 以上版本,可通过 gpg --version
检查,以下版本仍需wsl-ssh-pageant
等方法,可自行检索
本文假设你已经创建好了 Authenticate 用途的 subkey,可参考本文或自行检索
在 %AppData%\gnupg\gpg-agent.conf
中写入一行:
enable-win32-openssh-support
运行 gpg --list-keys --with-keygrip
获取 [A] Subkey 的 keygrip(Keygrip =
后的内容)
在 %AppData%\gnupg\sshcontrol
中写入你的 keygrip,以 LF 换行符的空行结尾
删除或设置 SSH_AUTH_SOCK
环境变量为 \\.\pipe\openssh-ssh-agent
重启 gpg-agent:
gpg-connect-agent killagent /bye
gpg-connect-agent /bye
有 connection to the agent established
的提示即可
运行 ssh-add -L
可获取对应的公钥
gpg agent 并不会开机自启,可在任务计划中(win+r,taskschd.msc)创建自启任务,触发器填写登录时
"C:\Program Files (x86)\GnuPG\bin\gpgconf.exe"
--launch gpg-agent
Linux
echo enable-ssh-support > ~/.gnupg/gpg-agent.conf
按照上文同样的方法填写 ~/.gnupg/sshcontrol
修改 ~/.bashrc(或~/.zshrc),添加下列内容
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent