我有一个 Yubikey 4,我想使用存储在其中的 GPG 密钥来对 SSH 服务器进行身份验证。
我想首先使用 GitHub。我已经将我的 GPG 身份验证密钥添加到 GitHub。
我的问题是,当我 ssh 时,我的代理不使用此密钥。我已经通过尝试连接到我的 VPS 进行了检查ssh -v,但它跳过了我的 GPG 密钥。我的 Yubikey 已插入并gpg2 --card-status显示所有详细信息。我能够很好地签名和解密以及使用 Yubikey 的其他功能。
ssh 输出
\n\ndebug1: Authentications that can continue: publickey\ndebug1: Next authentication method: publickey\ndebug1: Trying private key: /home/wilhelm/.ssh/id_rsa\ndebug1: Trying private key: /home/wilhelm/.ssh/id_dsa\ndebug1: Trying private key: /home/wilhelm/.ssh/id_ecdsa\ndebug1: Trying private key: /home/wilhelm/.ssh/id_ed25519\ndebug1: No more authentication methods to try.\nPermission denied (publickey).\nRun Code Online (Sandbox Code Playgroud)\n\n我已禁用 gnome 密码管理器。
\n\n我查看了Connecting SSH and Git to gpg-agent并遵循了建议,但它似乎不起作用。
\n\n\xe2\x95\xb0\xe2\x94\x80 ssh-add -l\nCould not open a connection to your authentication agent.\n\n\xe2\x95\xb0\xe2\x94\x80 ps aux | grep gpg-agent\nwilhelm 26079 0.0 0.0 20268 980 ? Ss 20:57 0:00 gpg-agent --daemon --enable-ssh-support --sh\nwilhelm 31559 0.0 0.0 12724 2184 pts/1 S+ 22:49 0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn gpg-agent\nRun Code Online (Sandbox Code Playgroud)\n
sshgpg-agent如果您不给它这样做的方式,则无法打开与您的连接。
当您启动gpg-agentwith--enable-ssh-support选项时,它会打印出需要在 shell 中可用的环境变量,您将在其中使用ssh. 获得它们的可能性很少:
停止gpg-agent并在您正在使用的 shell 中再次启动它ssh(这应该是测试它的最简单方法):
eval $(gpg-agent --daemon --enable-ssh-support --sh)
Run Code Online (Sandbox Code Playgroud)SSH_AUTH_SOCK找到认证socket的位置并手动设置环境变量
稍后,当您知道它可以工作时,您应该根据 的手册页设置代理启动gpg-agent(1),因此可能会~/.xsession让它自动启动。