gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 08:15:39 25 4
gpt4 key购买 nike

据我所知,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. Whenthe user logs in, the ssh program tells the server which key pair it would like to use forauthentication. The client proves that it has access to the private key and the server checksthat 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com