有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,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.
有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,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.
当前回答
这对我很有用
有2个选项在github - HTTPS/SSH
我错误地选择了SSH,因此出现了错误-_-
切换到HTTPS,然后复制url再次尝试:)
其他回答
我想我有最好的答案给你,你的git应用程序读取你的id_rsa。根用户目录下的Pub
/home/root/.ssh/id_rsa.pub
这就是为什么你的密钥在/home/your_username/.ssh/id_rsa中。少年犯看不懂酒吧。因此,您需要在/home/root/.ssh/中创建密钥
$ sudo su
$ ssh-keygen
$ cd ~/.ssh
$ cat id_rsa.pub
然后复制密钥在你的github帐户。 这对我很有效。你可以试试。
我在远程主机上使用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会话中转发它。点击这里查看更多细节。
如果您正在使用GitHub for Mac UI,请检查首选项以确保您已登录。
我也有同样的问题,但没有一个答案有效,但一个简单的解决方案有效。但是请注意,我确实首先添加了答案所建议的ssh密钥。不知道这是否真的有用。总之,这是最后成功的方法:
使用git远程将远程的URL从HTTPS更改为SSH set-url命令。$ git remote set-url origin git@github.com:USERNAME/REPOSITORY.git。验证远程URL 已经改变了。
对我来说,我试过这个
eval "$(ssh-agent -s)"
然后我就跑
ssh-add ~/.ssh/path-to-the-keyfile
为了生成密钥,你可以运行
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
这将生成一对密钥(Public和private)。
您可以将此密钥存储到github以了解更多信息,添加一个新的SSH密钥到您的github帐户
我希望它能帮助到其他人:)