有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,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.
当前回答
我想补充一些我的发现:
如果您正在使用GitBash,那么请确保SSH密钥存储在~/. SSH /id_rsa中。
默认情况下,git会搜索~/。ssh/id_rsaas ssh密钥的默认路径。
甚至文件名id_rsa也很重要。如果您将SSH密钥保存在另一个文件名或路径中,它将抛出Permission Denied(publickey)错误。
其他回答
这招对我很管用:
1-删除所有起源
git remote rm origin
(参见https://www.kernel.org/pub/software/scm/git/docs/git-remote.html)
*remote: "管理你所跟踪的分支的存储库集合("remotes")。
*rm: "删除已命名的远程。所有远程跟踪分支和远程配置设置都被删除。”
2-检查所有已删除:
git remote -v
3-添加新的产地主
git remote add origin git@github.com:YOUR-GIT/YOUR-REPO.git
这就是所有的朋友们!
另一个解决方案:
创建SSH密钥,输入SSH -keygen -t rsa -C "your_email@example.com"这将创建id_rsa和id_rsa。酒吧的文件。
将id_rsa添加到本地计算机的ssh列表:ssh- Add ~/.ssh/id_rsa。
生成密钥后获取pubkey使用:
cat ~/.ssh/id_rsa.pub
你会得到这样的东西:
cat ~/.ssh/id_rsa.pub
ssh-rsa AAAB3NzaC1yc2EAAAADAQABAAACAQCvMzmFEUPvaA1AFEBH6zGIF3N6pVE2SJv9V1MHgEwk4C7xovdk7Lr4LDoqEcqxgeJftwWQWWVrWWf7q9qCdHTAanH2Q5vx5nZjLB+B7saksehVOPWDR/MOSpVcr5bwIjf8dc8u5S8h24uBlguGkX+4lFJ+zwhiuwJlhykMvs5py1gD2hy+hvOs1Y17JPWhVVesGV3tlmtbfVolEiv9KShgkk3Hq56fyl+QmPzX1jya4TIC3k55FTzwRWBd+IpblbrGlrIBS6hvpHQpgUs47nSHLEHTn0Xmn6Q== user@email.com
复制这个密钥(值),到github.com,在设置(ssh和PGP密钥)下添加您的公钥。
我试图用几个小时来解决类似的问题。最后,我删除了所有的密钥,并创建了没有密码的新密钥,最终摆脱了这个问题。
问题是SSH密码,需要删除!
如果您将ssh访问更改为https访问远程存储库,问题就解决了:
git remote set-url origin https_link_to_repository
git push -u origin master
我在远程主机上使用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会话中转发它。点击这里查看更多细节。