当 git 通过 SSH 克隆而不添加 SSH 密钥时,服务器如何获取用户信息



我在执行以下命令时从 github 帐户 abd 中删除 ssh 密钥:

git clone git@xxx.git

它提示密码输入,我给出密码,但它给了我:

Permission denied, please try again.

我确保密码有效,因为我可以使用它来登录我的 github。我的困惑是服务器如何知道我是谁或git clone命令如何向服务器告诉我的身份?我怀疑也许服务器不知道我是谁,所以密码无法匹配。

服务器如何知道我是谁或 git clone 命令如何告诉我的身份

取决于协议。对于https://,您可以直接传递您的登录名/密码:

git clone https://user:passwd@example.com/repo.git

如果您未提供密码:

git clone https://user@example.com/repo.git

git要求它。

但是有了ssh协议

git clone ssh://git@example.com/repo.git

git clone git@example.com:repo.git

登录名是git因此服务器对您进行身份验证的唯一方法是通过 SSH 密钥对。也就是说,服务器必须知道您的公钥。

最新更新