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

我正在使用终端,我在根,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密钥,但仍然报错,这是因为您需要给用户读写要克隆到的文件夹的权限。sudo chmod 777 <your_folder_name_here>"。 当然,这是在生成SSH密钥之后,仍然会得到这个错误。希望这对未来的用户有所帮助。

Edit

如果你使用git bash,在Windows中使用admin来添加

其他回答

是的,我也有这个问题:/我要把我的项目推到Github的HTTP类型(不是SSH类型)。每次推送时我都必须输入用户名和密码。 因此,首先我输入了与以下类型相关的代码

git remote add origin git@github.com:YOUR-GIT/YOUR-REPO.git

我得到了

git@github.com:拒绝权限(publickey)。 无法从远程存储库读取。

因此,我通过以下方法解决了我的问题

Git远程rm来源删除你的Git远程存储库 Git远程现在检查您的远程存储库是否已被删除

网址= https://github.com/<username>/<repository>.git

再次添加您的URL,使远程存储库 Git push -u origin master 您可以将内容推送到远程存储库。在这里,当你在命令中使用"-u"时,你创建了一个跟踪分支,并且在远程存储库中的跟踪分支的帮助下,你不会告诉git你在接下来的步骤中推送哪个分支:) 如果你使用linux, git会在推送内容前询问用户名和密码。并提供你的相关证书。

为了防止在每次推送中提供用户名和密码,您必须更改git配置

对于列出你的git配置- git config——global——list 你会看到

user.name=<your_username>
user.email=<your_email>

所以你必须添加证书。Helper属性添加到git配置中 这个

5.Git配置——global——添加证书。助手存储将此添加到您的终端 现在你可以添加新的项目到你的文件,然后git add., git commit -m "<message>", git push 现在git也会要求你的用户名和密码,这将是最后一次。下一个git推送git不会向你请求用户名和密码:)

你需要生成一个SSH密钥(如果你没有的话),并将公钥与你的Github帐户相关联。参见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

这发生在我身上。出于某种原因,我的出身在我没有意识到的情况下被搞砸了:

检查您的设置是否仍然正确

git remote -v

url需要像ssh://git@github.com/YourDirectory/YourProject.git; 如果没有看到git@github.com,请使用

git remote set-url origin git://github.com/YourDirectory/YourProject.git

纠正错误。或者你可以使用github应用程序在特定存储库的设置面板中检查和设置主远程存储库url。

这对我很有用

有2个选项在github - HTTPS/SSH

我错误地选择了SSH,因此出现了错误-_-

切换到HTTPS,然后复制url再次尝试:)