繁体   English   中英

GitHub 权限被拒绝(公钥)

[英]GitHub Permission Denied (publickey)

我一直在尝试这样做,但每次尝试克隆它时都会发生这种情况。

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.

一个 ssh 网址意味着:

如果您没有创建任何 ssh 密钥,那么正如评论的那样,您可以尝试使用不需要任何身份验证的 https url(至少用于克隆)

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

我刚刚遇到了类似的问题,我终于解决了。

我的解决办法是:

首先,按照此处的说明检查Github 的现有密钥,如果没有,则创建一个 不要只是复制和粘贴代码,请仔细阅读说明,因为有些代码您必须修改和自定义。

顺便说一句,在这一步,我在尝试修改我的 ~/.ssh/id_rsa 文件时遇到了麻烦,但事实证明这没什么大不了的。 但是,如果您真的想存储您的 SSH 密钥并避免每次推送和拉取时都输入它,您可以转到您的 .ssh 目录并通过有用的 'nano' 创建一个 'config' 文件并输入以下内容:

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

其次,将您的 SSH 密钥复制到剪贴板。 提到了这一步但没有在详细步骤中说明,我的方法是:

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

我确信一定有更好的方法,但它们对我不起作用,可能是因为我在 git 中打开文本编辑器时遇到问题。

第三, 刚刚生成的密钥添加到您的 Github 帐户中。

如果你做了所有这些,你的 git 可能会像我的一样工作。

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

您需要使用https URL ( https://github.com/...someThing )。 使用您使用的那个只有在您对存储库具有推送访问权限时才有效。

暂无
暂无

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

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