如何让我的 Yubikey 在 Windows 10 中与 SSH 一起工作?

How do I get my Yubikey to work with SSH in Windows 10?

出于技术兴趣购买了 Yubikey 5 NFC(固件 5.2.7)并在可能的情况下设置了 FIDO2 身份验证后,我 运行 遇到了无法再连接到 Git 的问题通过 SmartGit 的实验室服务器,因为没有请求第二个因素,因此我无法连接到服务器。

然后我决定在 Windows 10 通过 Git Bash 和 SSH 处理它。不幸的是,此处的文档假设了很多先验知识,而我是该主题的绝对初学者。与此同时,我设法使用 Git Bash 和 SSH 使用本地生成的 SSH 证书连接到服务器。

现在我想用Yubikey代替电脑本地存储的证书。不幸的是,所有说明(例如这个 https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key-for-a-hardware-security-key)都会对我导致相同的错误消息:

$ ssh-keygen -t ed25519-sk -C "name@mail.com"
Generating public/private ed25519-sk key pair.
You may need to touch your authenticator to authorize key generation.
Key enrollment failed: invalid format

在此之前,系统提示我输入 PIN。有趣的是:消息看起来一模一样,我是否插入了 Yubikey 都没有关系。使用 ecdsa-sk 的尝试导致相同的结果。

(顺便说一下,我已经在 Yubikey 上成功存储了一个 OpenPGP 证书。)

现在我也阅读了一些关于 libfido2 的内容,但是我在 Windows 10.

上找不到任何关于如何使用它的说明

所以我的问题是:我如何设法使用我的 Yubikey 而不是我的本地密钥? 或者:如果这是问题,我该如何安装 libfido2?

2021 年 5 月

所以:是的Security keys are now supported for SSH Git operations , as announced early this month (May 2021) on GitHub, but, as discussed here,还有问题

您的错误消息看起来像是 Debian 上的错误:“issue 980393: /usr/bin/ssh-keygen -t ecdsa-sk fails with "Key enrollment failed: invalid format"”。
它是 still being reported this month.

如果 -t ecdsa 也失败了,尝试使用 a plugin for OpenSSH to connect to FIDO/U2F security keys through native Windows Hello APIs 可能会有帮助。
首先键入 export SSH_SK_HELPER=/usr/lib/ssh/ssh-sk-helper.exe,如 tavrez/openssh-sk-winhello issue 1.
所示 检查您的 OpenSSH 版本至少为 8.2。最新的 Git for Windows:

在我这边
ssh -V
OpenSSH_8.5p1, OpenSSL 1.1.1k  25 Mar 2021

OP DroidDroid adds in :

Nevertheless, I now have the problem that GitLab doesn't support security keys yet: issue 213259


二月。 2022 年:GitLab 现在应该支持这些安全密钥。

参见 GitLab 14.8(2022 年 2 月)

Support for ecdsa-sk and ed25519-sk SSH keys

OpenSSH 8.2 added support for FIDO/U2F hardware authenticators with new ecdsa-sk and ed25519-sk key types.

GitLab now supports these key types, allowing users to take advantage of hardware-backed SSH authentication.

https://about.gitlab.com/images/14_8/ssh_key.png -- Support for ecdsa-sk and ed25519-sk SSH keys

See Documentation and Issue.