有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,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访问更改为https访问远程存储库,问题就解决了:
git remote set-url origin https_link_to_repository
git push -u origin master
其他回答
以防有人需要这个。我在用户的.ssh文件夹中创建了一个不同名称的ssh密钥,如ar-2022-ssh。这样做的问题是,检查现有的SSH密钥指定GitHub支持的公钥是以下之一。
id_rsa.pub
id_ecdsa.pub
id_ed25519.pub
一旦我在生成密钥时将我的ssh密钥名称更改为其中之一,它就可以连接到GitHub
排除故障的步骤
这发生在SourceTree上 在我的例子中,我的公私钥对出了问题。所以我删除这对并生成一个新的来解决我的问题
TLDR:
确保您拥有对回购的写访问权限(从回购的设置中进行配置)。 确保公钥在你的github帐户的SSH和GPG密钥中。
对我来说,这个错误通常发生在我试图从新安装的机器上克隆一些repo时。当收到请求时,github将首先检查公钥哈希。如果公钥不匹配任何用户,github将拒绝此请求。如果机器是新的,并且您的ssh密钥是新生成的,则这种情况很常见。
如果您正在使用GitHub for Mac UI,请检查首选项以确保您已登录。
我想我有最好的答案给你,你的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帐户。 这对我很有效。你可以试试。