简体   繁体   English

GitHub 权限被拒绝(公钥)

[英]GitHub Permission Denied (publickey)

I've been trying to do this but this is what is happening every time I try to clone this.我一直在尝试这样做,但每次尝试克隆它时都会发生这种情况。

C:\Users\Cod>git clone git@github.com:MiniCodeMonkey/Vagrant-LAMP-Stack.git
Cloning into 'Vagrant-LAMP-Stak'...
The authenticity of host 'github.com (192.30.252.128)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.128' (RSA) to the list of know
n hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

An ssh url means:一个 ssh 网址意味着:

If you didn't created any ssh key, then as commented, you can try instead using the https url, which doesn't require any authentication (for cloning at least)如果您没有创建任何 ssh 密钥,那么正如评论的那样,您可以尝试使用不需要任何身份验证的 https url(至少用于克隆)

git clone https://github.com/MiniCodeMonkey/Vagrant-LAMP-Stack

I was just having a similar issue, and I finally solved it.我刚刚遇到了类似的问题,我终于解决了。

My solution is:我的解决办法是:

First, follow the instruction here to check for existing key for Github, and create one if there isn't any.首先,按照此处的说明检查Github 的现有密钥,如果没有,则创建一个 Do not just copy and paste the code, read the instruction carefully because there are some code you must modify and customize.不要只是复制和粘贴代码,请仔细阅读说明,因为有些代码您必须修改和自定义。

BTW, at this step, I was having trouble while trying to modifying my ~/.ssh/id_rsa file, but it turned out this is not a big deal.顺便说一句,在这一步,我在尝试修改我的 ~/.ssh/id_rsa 文件时遇到了麻烦,但事实证明这没什么大不了的。 However, if you really want to store your SSH key and avoid entering it every time you push and pull, you can go to your .ssh directory and make a 'config' file by useful 'nano' and enter the following:但是,如果您真的想存储您的 SSH 密钥并避免每次推送和拉取时都输入它,您可以转到您的 .ssh 目录并通过有用的 'nano' 创建一个 'config' 文件并输入以下内容:

Host *
 AddKeysToAgent yes
 UseKeychain yes
 IdentityFile ~/.ssh/id_rsa

Second, copy your SSH key to the clipboard.其次,将您的 SSH 密钥复制到剪贴板。 This step is mentioned but not illustrated in detailed step, my way to do this is:提到了这一步但没有在详细步骤中说明,我的方法是:

cd ~
ls -a
cd .ssh
cat id_rsa.pub

I am sure there must be better ways, but they do not work out for me, probably because I am having trouble opening text editor within git.我确信一定有更好的方法,但它们对我不起作用,可能是因为我在 git 中打开文本编辑器时遇到问题。

Third, add the key you just generate to your Github account.第三, 刚刚生成的密钥添加到您的 Github 帐户中。

If you do all these, your git might work just fine like mine did.如果你做了所有这些,你的 git 可能会像我的一样工作。

All references from: https://help.github.com/articles/connecting-to-github-with-ssh/#generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent所有参考资料来自: https : //help.github.com/articles/connecting-to-github-with-ssh/#generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

You need to use the https URL ( https://github.com/...someThing ).您需要使用https URL ( https://github.com/...someThing )。 Using the one you used only works when you have push access to the repository.使用您使用的那个只有在您对存储库具有推送访问权限时才有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM