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

我正在使用终端,我在根,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密钥(如果你没有的话),并将公钥与你的Github帐户相关联。参见Github自己的文档。

其他回答

可能您的ssh-agent未启用 你可以试试

下载

http://git-scm.com/

安装它 使ssh-agent

C:\Program Files\Git\cmd

start-ssh-agent

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

你可以试试这种方法……

选择其他链接

我在'git push'期间得到相同的错误。在客户端,我有两个起源和主人。我拿掉了一个,然后它就正常工作了。

我在远程主机上使用git pull寻找类似错误消息的解决方案时发现了这个页面:

$ git pull
Permission denied (publickey).
fatal: Could not read from remote repository.

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

我通过ssh -AY remote_hostname从本地计算机连接到远程主机。这不是OP问题的解决方案,但对其他遇到这个页面的人很有用,所以把它贴在这里。

注意,在我的例子中,git pull在我的本地机器上工作良好(也就是说,ssh密钥已经设置,并添加到GitHub帐户等)。我通过将这个添加到~/来解决我的问题。Ssh /config在我的笔记本电脑:

Host *
     ForwardAgent yes

然后我用ssh -AY remote_hostname重新连接到远程主机,git拉现在工作了。配置中的更改允许将我的ssh对从本地计算机转发到任何主机。ssh的-A选项实际上是在ssh会话中转发它。点击这里查看更多细节。