我首先为我的 github 生成了一个 key 。然后将其添加到 和 ID 。将 id_rsa.pub 的内容复制到我的 github 帐户中并使用以下命令测试连接:
ssh -T <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="adcac4d9edcac4d9c5d8cf83cec2c0" rel="noreferrer noopener nofollow">[email protected]</a>
接下来是:
The authenticity of host 'github.com (***.**.***.*)' can't be established.
RSA key fingerprint is SHA****:************************************.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,***.**.***.' (RSA) to the list of known hosts.
Hi ****! You've successfully authenticated, but GitHub does not provide shell access.
在尝试推送某些内容后,它仍然询问我的用户名和密码,我不知道为什么。
最佳答案
您当前的 Remote 将使用 https 协议(protocol)。这就是为什么它仍然要求输入密码。
使用git remote show origin | grep URL
查看当前的远程 URL 来源
如果以 https://
开头它会要求输入用户名和密码。
然后通过git remote rm origin
删除它
然后通过 git remote add origin <url>
添加 ssh url
确保您在此处提供 ssh url,它应该类似于 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="04636d7044636d706c71662a676b69" rel="noreferrer noopener nofollow">[email protected]</a>..
转到您的 github 存储库并单击绿色克隆按钮,如果它是 https 格式,请将其更改为 ssh
使用Use SSH
将其更改为 SSH 的链接
然后你应该看到 ssh url
关于git - ssh key github 添加后仍询问 user/pw,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59174302/