执行以下命令时,我从 github 帐户 abd 中删除了 ssh key :
git clone <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a8cfc1dce8d0d0d086cfc1dc" rel="noreferrer noopener nofollow">[email protected]</a>
它提示输入密码,我给出密码,但它给了我:
Permission denied, please try again.
我确保密码有效,因为我可以用它登录我的 github。我的困惑是服务器如何知道我是谁,或者 git clone 命令如何将我的身份告诉服务器?我怀疑服务器可能不知道我是谁,所以密码无法匹配。
最佳答案
how the server know who am I or how git clone command tell the Identity of me
取决于协议(protocol)。对于 https://
,您直接传递您的登录名/密码:
git clone https://user:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bacadbc9c9cddefadfc2dbd7cad6df94d9d5d7" rel="noreferrer noopener nofollow">[email protected]</a>/repo.git
如果您不提供密码:
git clone https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="88fdfbedfac8edf0e9e5f8e4eda6ebe7e5" rel="noreferrer noopener nofollow">[email protected]</a>/repo.git
git
要求它。
但是使用ssh
协议(protocol)
git clone ssh://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2a4d435e6a4f524b475a464f04494547" rel="noreferrer noopener nofollow">[email protected]</a>/repo.git
或
git clone <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="75121c0135100d14180519105b161a18" rel="noreferrer noopener nofollow">[email protected]</a>:repo.git
登录名是git
,因此服务器对您进行身份验证的唯一方法是通过 ssh key 对。也就是说服务器必须知道你的公钥。
关于git - 通过ssh git clone 时服务器如何获取用户信息而不添加ssh key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55649042/