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

我正在使用终端,我在根,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帐户时遇到问题,请按照以下步骤进行

解决方案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

其他回答

我想我有最好的答案给你,你的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帐户。 这对我很有效。你可以试试。

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

这招对我很管用:

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密码,需要删除!

我在远程主机上使用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会话中转发它。点击这里查看更多细节。