我可以在本地使用 RSA 密钥测试身份验证吗?

发布于 2024-09-27 00:35:22 字数 630 浏览 2 评论 0原文

有没有办法在本地检查您是否为 RSA 密钥提供了正确的密码?

最近,我在将一些提交推送到 github 时遇到了麻烦,因为推送提示输入密码,然后身份验证失败。我验证了 github 具有我的 ~/.ssh 目录中的 id_rsa 文件的正确公钥,并且我验证了我可以通过 Github 进行身份验证(如果您 ssh [email protected] 它会告诉您您已通过身份验证,但是他们不提供 shell 访问,)所以我知道问题出在我这边,而不是 Github 的。

(我应该指出,此时我只是使用 git format-patch 来将我的提交作为文件获取,然后删除我的工作存储库并从 Github 重新克隆,使用 重新应用补丁git am,并且没有任何问题地推送,所以无论最初的问题是什么,它都已解决。)

但这让我想知道:我如何知道远程主机的身份验证问题是否是我提供了错误的密码我的私钥,还是远程主机无法识别我的密钥?有没有办法在本地使用私钥进行测试身份验证,而无需尝试连接到远程主机?

Is there a way to check locally if you're providing the correct passphrase to an RSA key?

I recently had trouble pushing some commits to github because the push prompted for a password and then failed authentication. I verified that github had the correct public key for the id_rsa file in my ~/.ssh directory, and I verified that I could authenticate with Github (if you ssh [email protected] it will tell you you authenticated but that they don't offer shell access,) so I knew the problem was on my end, not Github's.

(I should point out that at this point I simply used git format-patch to get my commits as files, then blew away my working repository and re-cloned from Github, reapplied the patches using git am, and pushed without any trouble, so whatever the original problem was, it's fixed.)

This left me wondering, though: how would I know if an authentication problem with a remote host was me providing the wrong passphrase to my private key, or the remote host not recognizing my key? Is there a way to do a test authentication with the private key, locally, without trying to connect to a remote host?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

没︽人懂的悲伤 2024-10-04 00:35:22

或者正如这里所指出的:
如何在本地测试我的 ssh 密钥而无需服务器

你可以这样做:

ssh-keygen -y

这不需要任何服务器(在 Windows 上与 msysgit 配合使用效果很好)。

Or as pointed here:
How can I test my ssh-keys locally without a server

You can do this:

ssh-keygen -y

And this doesn't require any server (works great with msysgit on Windows).

烟织青萝梦 2024-10-04 00:35:22

您可以运行 ssh-add 将密钥添加到当前的 ssh-agent 中。这将提示您输入密码。

通常,当 ssh-agent 正在运行并且您向其添加密钥时,当您连接到识别该密钥的主机时,您将不再需要解锁密钥。如果这不是您想要的,只需在完成测试后运行 ssh-add -d 将其从 ssh-agent 中删除。

You can run ssh-add to add your key to your current ssh-agent. This will prompt for your passphrase.

Normally, when ssh-agent is running, and you add a key to it, you won't have to unlock your key any more when you connect to hosts that recognise that key. If that isn't what you want, just run ssh-add -d to remove it off your ssh-agent when you're done testing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文