有人看到这个错误并知道该怎么做吗?

我正在使用终端,我在根,GitHub存储库存在,我不知道现在该做什么。

> git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

当前回答

我在ssh代理中加载了2个Github身份文件。我的个人钥匙和另一把客户项目的钥匙。

我删除了引起混乱的关键:

Ssh-add -d id_rsa_github_somekey . sh

其他回答

如果您正在使用GitHub for Mac UI,请检查首选项以确保您已登录。

设置SSH访问GitHub的完整步骤已经发布在ServerFault上。

查看来自@Alex的答案:https://serverfault.com/a/1088209/416091

在2022年7月24日,我应该在SSH用户配置文件(~/. SSH /config)中将服务器和端口设置为SSH .github.com:443。

这发生在我身上。出于某种原因,我的出身在我没有意识到的情况下被搞砸了:

检查您的设置是否仍然正确

git remote -v

url需要像ssh://git@github.com/YourDirectory/YourProject.git; 如果没有看到git@github.com,请使用

git remote set-url origin git://github.com/YourDirectory/YourProject.git

纠正错误。或者你可以使用github应用程序在特定存储库的设置面板中检查和设置主远程存储库url。

如果您正在使用windows -10,请遵循此说明。这对我很管用。

以管理员身份打开终端 执行命令:"ssh-keygen"。它生成一个ssh密钥,并显示创建密钥的文件夹。检查我的图像 复制生成的ssh密钥 点击“新建SSH键按钮”并粘贴“SSH键”,最后“点击添加按钮”

如果您将ssh访问更改为https访问远程存储库,问题就解决了:

git remote set-url origin https_link_to_repository

git push -u origin master