我使用 yubikey 通过 ssh 验证远程主机的身份。这在 Linux 上有效(使用相同的密钥),但在 Windows 上使用 git-bash 则失败。
所有这些都是在 Windows 10 上,这是 OpenSSH_9.0p1,OpenSSL 1.1.1p 2022 年 6 月 21 日
这是错误信息。为什么签名失败?
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/Andreas/.ssh/id_ohnering_sk ED25519-SK SHA256:C2BdL8/gLMbP6ktTI/Z22+FhZ51VbPhvxnto7GYxkj4 explicit authenticator agent
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: /c/Users/Andreas/.ssh/id_ohnering_sk ED25519-SK SHA256:C2BdL8/gLMbP6ktTI/Z22+FhZ51VbPhvxnto7GYxkj4 explicit authenticator agent
sign_and_send_pubkey: signing failed for ED25519-SK "/c/Users/Andreas/.ssh/id_ohnering_sk" from agent: agent refused operation
debug1: Offering public key: /c/Users/Andreas/.ssh/id_ring_sk ED25519-SK SHA256:chjSSXPpiBHI+0MnO8v51yC8632tKr358BPGUubkrto explicit authenticator agent
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: /c/Users/Andreas/.ssh/id_ring_sk ED25519-SK SHA256:chjSSXPpiBHI+0MnO8v51yC8632tKr358BPGUubkrto explicit authenticator agent
sign_and_send_pubkey: signing failed for ED25519-SK "/c/Users/Andreas/.ssh/id_ring_sk" from agent: agent refused operation
debug1: Offering public key: /c/Users/Andreas/.ssh/id_rsa RSA SHA256:5sI4OvJOs6+7RcD76iomtR6geCSBoZ5397jeWzNlspE agent
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).
代理人有钥匙
ssh-add -l
4096 SHA256:5sI4OvJOs6+7RcD76iomtR6geCSBoZ5397jeWzNlspE /c/Users/andreas/.ssh/id_rsa (RSA)
256 SHA256:C2BdL8/gLMbP6ktTI/Z22+FhZ51VbPhvxnto7GYxkj4 andreas@salomon (ED25519-SK)
256 SHA256:chjSSXPpiBHI+0MnO8v51yC8632tKr358BPGUubkrto andreas@salomon (ED25519-SK)
这是我的密钥的权限(在 Windows 上)
ls -al .ssh
total 85
drwxr-xr-x 1 Andreas 197121 0 Jul 7 16:24 ./
drwxr-xr-x 1 Andreas 197121 0 Jul 7 16:27 ../
-rw-r--r-- 1 Andreas 197121 1471 Jun 17 13:46 config
-rw-r--r-- 1 Andreas 197121 407 Jul 6 2021 id_mykey_sk
-rw-r--r-- 1 Andreas 197121 144 Jul 6 2021 id_mykey_sk.pub
-rw-r--r-- 1 Andreas 197121 561 Jun 17 13:33 id_ohnering_sk
-rw-r--r-- 1 Andreas 197121 144 Jun 17 13:33 id_ohnering_sk.pub
-rw-r--r-- 1 Andreas 197121 561 Jun 17 13:33 id_ring_sk
-rw-r--r-- 1 Andreas 197121 144 Jun 17 13:33 id_ring_sk.pub
-rw-r--r-- 1 Andreas 197121 4583 May 17 13:50 known_hosts
显然,这些权限在 Linux 上是不够的。在 Windows 上可以吗?我似乎无法将它们设置为 600。不过,我不认为这是问题所在。
这是怎么回事?我怎样才能让它工作?
答案1
看来这是需要以管理员身份运行 git-bash 才能访问 USB 设备的问题。(即使是原始的 yubikey 工具也需要以管理员身份运行才能访问。)第二个问题是 lib 路径中的旧 winhello.dll。我删除了它。然后我能够在 Windows 上生成一个新的 ED25519_SK 密钥,并且我能够使用该密钥进行身份验证。