git - ssh key github 添加后仍询问 user/pw

标签 git github ssh ssh-keys

我首先为我的 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 enter image description here

使用Use SSH将其更改为 SSH 的链接

然后你应该看到 ssh url

enter image description here

关于git - ssh key github 添加后仍询问 user/pw,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59174302/

相关文章:

git - 使用 git 推送和 pull 时出现 SSL 错误

android - 如何对 Github 上的 Android 项目进行版本控制以及不同团队成员使用 intellij 和 eclipse IDE?

curl - 使用 wget/curl 下载 Github 构建工件(发布)

mysql - 挂载 LVM2 并从故障 HDD 中恢复丢失的数据?

python - 使用同一个 SSH 对象在 Paramiko 中多次发出 "exec_command()"

ssh 配置可以在家里工作,但不能从另一个目录工作

GIT Diff 在许多文件上说 100644 → 100755

git - 检查分支是否已经 merge 到远程的 master 或 dev 分支中

git - 如何让 Git pull 默认为我的所有存储库使用 rebase?

xcode - 创建新项目并将项目添加到 gitHub 时出错 : Server Unreachable