有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,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.
当前回答
设置SSH访问GitHub的完整步骤已经发布在ServerFault上。
查看来自@Alex的答案:https://serverfault.com/a/1088209/416091
在2022年7月24日,我应该在SSH用户配置文件(~/. SSH /config)中将服务器和端口设置为SSH .github.com:443。
其他回答
我最近也遇到了同样的问题。如果您需要立即修复,这可能会有所帮助,但每次重新启动系统时都需要这样做
在终端执行:ssh-add ~/.ssh/id_rsa
输入系统密码就可以了。
我想补充一些我的发现:
如果您正在使用GitBash,那么请确保SSH密钥存储在~/. SSH /id_rsa中。
默认情况下,git会搜索~/。ssh/id_rsaas ssh密钥的默认路径。
甚至文件名id_rsa也很重要。如果您将SSH密钥保存在另一个文件名或路径中,它将抛出Permission Denied(publickey)错误。
在将GitHub添加为远程时,使用该页面的URL。 它不会引起任何这样的错误和推动代码
我在远程主机上使用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会话中转发它。点击这里查看更多细节。
我也遇到了这个问题,因为我使用了几个GIT帐户,以及工作和大学的不同帐户,这对我来说很有效:
->进入您的SSH配置
cd ~/.ssh/
vim config
->复制下面的块,并填写您想要推送到/with的主机和用户
Host [Hostname]
User [User]
PubkeyAcceptedAlgorithms +ssh-rsa
HostkeyAlgorithms +ssh-rsa
我得到这个问题的几个主机名,所以现在我有几个这些配置在我的ssh配置文件。