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

我正在使用终端,我在根,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.

当前回答

这对我很有用

有2个选项在github - HTTPS/SSH

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

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

其他回答

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

对我来说,我试过这个

eval "$(ssh-agent -s)"

然后我就跑

ssh-add ~/.ssh/path-to-the-keyfile

为了生成密钥,你可以运行

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

这将生成一对密钥(Public和private)。

您可以将此密钥存储到github以了解更多信息,添加一个新的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

我在之前的一个php项目中使用github。在使用github时,我使用的是ssh而不是https。我把我的机器设置成这样,每次我提交和推送代码时,它会问我的rsa密钥密码。

几天后,我停止了php项目的工作,忘记了我的rsa密码。最近,我开始在一个java项目上工作,并搬到了bitbucket。因为,我忘记了密码,没有办法恢复它,我猜,我决定使用https(推荐)协议的新项目,并得到了同样的错误在问题中询问。

我是怎么解决的?

运行这个命令告诉我的git使用https而不是ssh: Git配置——全局url."https://"。与其使用git: / / 如果有遥控器,移除遥控器 Git远程rm来源 重做一切从git init到git push,它工作!

PS:我还在调试过程中从我的机器上卸载了ssh,以为删除它就能解决问题。是的,我知道!:)

允许对密钥(标识)进行写访问,然后单击“添加密钥”

如果在Windows上,请检查通过SSH使用Github中的更多详细信息。