GitHub错误消息-权限被拒绝(公钥)

本文翻译自:GitHub Error Message - Permission denied (publickey)

Anybody seen this error and know what to do? 有人看到此错误并知道该怎么办吗?

I'm using the terminal, I'm in the root, the GitHub repository exists and I don't know what to do now. 我正在使用终端,我在根目录中,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.

#1楼

参考:https://stackoom.com/question/sIRm/GitHub错误消息-权限被拒绝-公钥


#2楼

You need to generate an SSH key (if you don't have one) and associate the public key with your Github account. 您需要生成一个SSH密钥(如果您没有SSH密钥),并将公钥与您的Github帐户相关联。 See Github's own documentation . 请参阅Github自己的文档


#3楼

GitHub isn't able to authenticate you. GitHub无法验证您的身份。 So, either you aren't setup with an SSH key, because you haven't set one up on your machine , or your key isn't associated with your GitHub account. 因此,或者您没有设置SSH密钥,因为您尚未在计算机上进行设置 ,或者您的密钥未与GitHub帐户相关联。

You can also use the HTTPS URL instead of the SSH/git URL to avoid having to deal with SSH keys. 您也可以使用HTTPS URL代替SSH / git URL,以避免必须处理SSH密钥。 This is GitHub's recommended method . 这是GitHub的推荐方法

Further, GitHub has a help page specifically for that error message , and explains in more detail everything you could check. 此外,GitHub上有一个专门针对该错误消息帮助页面 ,并详细说明了您可以检查的所有内容。


#4楼

This happened to me. 这发生在我身上。 For some reason my origin got messed up without my realizing it: 由于某种原因,我的出身被弄乱了,却没有意识到:

Check if your settings are still correct 检查您的设置是否仍然正确

git remote -v

the url needs to be something like ssh://git@github.com/YourDirectory/YourProject.git; 网址必须类似于ssh://git@github.com/YourDirectory/YourProject.git; if you don't see git@github.com, use 如果看不到git@github.com,请使用

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

to set it right. 设置正确。 Or you could use the github app to check and set the Primary Remote Repository url in the settings panel of your particular repository. 或者,您可以使用github应用程序在特定存储库的设置面板中检查并设置主远程存储库url。


#5楼

First, we need to check for existing ssh keys on your computer. 首先,我们需要检查计算机上现有的ssh密钥。 Open up Terminal and run: 打开终端并运行:

ls -al ~/.ssh

#or

cd ~/.ssh
ls

and that will lists the files in your .ssh directory 这将列出您的.ssh目录中的文件

And finally depending on what you see (in my case was): 最后取决于您看到的内容(以我为例):

 github_rsa  github_rsa.pub known_hosts

Just try setting up your RSA and hopefully that will solve your "git push origin" issues 只需尝试设置您的RSA,并希望能解决您的“ git push origin”问题

$ ssh-keygen -lf ~/.ssh/github_rsa.pub

NOTE: RSA certificates are keys-paired so you will have a private and a public certificate, private will not be accessible for you since it belongs to github (in this case) but the public is the one you might be missing when this error happens (at least that was my case, my github account or repo got messed up somehow and i had to "link" the public key, previously generated) 注意: RSA证书是密钥对,因此您将拥有一个私有证书和一个公共证书,因为它属于github(在这种情况下),所以私有证书将无法被您访问,但是当发生此错误时,公共证书是您可能会丢失的一个证书(至少这是我的情况,我的github帐户或回购以某种方式弄乱了,我不得不“链接”先前生成的公钥)


#6楼

Did you create a config file in your ~/.ssh directory? 您是否在〜/ .ssh目录中创建了一个配置文件? It should have contents like these: 它应具有以下内容:

Host github.com 
 IdentityFile ~/.ssh/github_rsa

Assuming that you created an ssh key named github_rsa 假设您创建了一个名为github_rsa的ssh密钥

and uploaded it to GitHub... 并上传到GitHub ...

NOTE: You must follow this way of explicit configuration if you have more than 1 key (2 and more) in your ~/.ssh/ directory. 注意:如果〜/ .ssh /目录中有1个以上的键(2个或更多),则必须遵循这种显式配置方式。 If you don't specify key this way, then first key in order is taken and used for github authentication, so it depends on the key file name then. 如果您不以这种方式指定密钥,那么将按顺序使用第一个密钥并将其用于github身份验证,因此它取决于密钥文件名。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值