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

我正在使用终端,我在根,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 /文件夹,即id。Rsa和id.rsa.pub 确保密钥有正确的权限,你可以运行chmod: Chmod 600 ~/.ssh/id_rsa . exe Chmod 644 ~/.ssh/id_rsa.pub 确保您的公钥(id_rsa.pub)的内容与远程存储库配置中上传的内容匹配 最后修复ssh代理的问题: ssh-add

更多信息:https://itcodehub.blogspot.com/2015/01/ssh-add-problems-with-ssh-agent-and.html

其他回答

使用Https是可以的,运行git config——global credential。帮助wincred创建一个Github凭据帮助存储您的凭据为您。如果这不起作用,那么您需要编辑.git目录中的配置文件,并将原始文件更新为https url。

查看github文档的链接。

排除故障的步骤

这发生在SourceTree上 在我的例子中,我的公私钥对出了问题。所以我删除这对并生成一个新的来解决我的问题

以防有人需要这个。我在用户的.ssh文件夹中创建了一个不同名称的ssh密钥,如ar-2022-ssh。这样做的问题是,检查现有的SSH密钥指定GitHub支持的公钥是以下之一。

id_rsa.pub
id_ecdsa.pub
id_ed25519.pub

一旦我在生成密钥时将我的ssh密钥名称更改为其中之一,它就可以连接到GitHub

如果您在连接您的企业Github帐户时遇到问题,请按照以下步骤进行

解决方案1

ERROR: git@github.com: Permission denied (public key). fatal: Could not read
from remote repository. Please make sure you have the correct access
rights

解决方案(OSX)

打开终端并执行以下命令 $ CD ~ $ sudo su ssh - keygen美元 输入要保存密钥的文件(/var/root/.ssh/id_rsa): $ id_rsa Enter passphrase(空表示没有passphrase): $ hit Enter 再次输入相同的密码:$ hit Enter $ CD ~/.ssh $ cat id_rsa.pub 复制显示内容。 打开GitHub单击您的配置文件图标设置>SSH和GPC密钥 单击新的ssh键按钮 输入您复制的任何标题和键 检查您的问题是否已经解决

解决方案2

ERROR 2: remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.
remote: See https://github.compnay.com/settings/tokens or https://github.compnay.com/settings/ssh
fatal: unable to access 'https://github.company.com/repo/app.git/': The requested URL returned an error: 403

密码认证支持已于2021年8月13日移除。请改用个人访问令牌。

https://namespaceit.com/blog/remote-support-for-password-authentication-was-removed-on-august-13-2021-please-use-a-personal-access-token-instead

你需要生成一个SSH密钥(如果你没有的话),并将公钥与你的Github帐户相关联。参见Github自己的文档。