authentication - SSH 公钥身份验证如何工作(选择正确的 key )

标签 authentication github ssh cryptography

据我所知,SSH 身份验证以及根据 Alice 和 Bob 的许多解释,有一些主要步骤:

  1. 客户端生成一对公钥/私钥并将公钥发布到服务器。
  2. 当服务器收到公钥认证请求时,会生成一个随机数据,用客户端的公钥对其进行加密并发送给客户端。
  3. 客户端使用私钥解密该数据并将其发送回作为真实性证明。

我希望你们中的一些人帮助我理解当我通过 SSH 协议(protocol)克隆任意存储库时,GitHub 服务器如何知道在步骤 2 中选择哪个公钥? 它有数百万个用户公钥可供选择。用户可能在他的机器上安装了许多私钥。

最佳答案

该协议(protocol)比您想象的要复杂一些。联机帮助页描述了客户端告诉服务器它想要使用哪个 key :

The file ~/.ssh/authorized_keys lists the public keys that are permitted for logging in. When the user logs in, the ssh program tells the server which key pair it would like to use for authentication. The client proves that it has access to the private key and the server checks that the corresponding public key is authorized to accept the account.

relevant SSH rfc客户端实际上通过 SSH_MSG_USERAUTH_REQUEST 请求发送整个公钥的详细信息。

在大多数情况下,使用公钥 github 应该能够找到相应的用户。不过,我不知道当两个帐户共享 key 时会发生什么。

关于authentication - SSH 公钥身份验证如何工作(选择正确的 key ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23580283/

相关文章:

linux - ssh 命令引用有什么区别?

java - 使用纯 Java 与 SSH 服务器通信以进行文件访问

java - 当从 java VM 调用设置 cookie 的 REST 服务时,cookie 是如何工作的?

Xcode 9.2 无法为主分支配置 git 源代码控制

github - 如何评论未显示的二进制文件的 Github 拉取请求

github - 无论如何可以在类似于图像的github自述文件中查看STL文件?

java - 甘尼梅德 ssh2 : how to solve (y/n) prompt in command line

javascript - 如何允许用户在不经过身份验证/登录过程的情况下查看我的 Google Analytics 图表数据

javascript - Instagram oAuth Authentication postMessage 问题仅适用于移动浏览器

php - 我的 php 网站的 gmail 身份验证