git 尝试匿名克隆 github 存储库时权限被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16187849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:01:43  来源:igfitidea点击:

Permission denied when trying to anonymously clone a github repository

gitgithub

提问by Michael H?rtl

As an anonymous user (no public key stored at github) I try to clone a public repository through the git@...URL. But it fails:

作为匿名用户(github 上没有存储公钥),我尝试通过git@...URL克隆一个公共存储库。但它失败了:

$ git clone [email protected]:mikehaertl/phpwkhtmltopdf.git
Cloning into 'phpwkhtmltopdf'...
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

So does this mean, github does not allow anonymous access through the SSH protocol? If so, is this documented somewhere?

那么这是否意味着,github 不允许通过 SSH 协议进行匿名访问呢?如果是这样,这是否记录在某处?

回答by Michael H?rtl

I just found out that there's another button at github that says "Git Read-only". It gives a similar but slightly different URL that works:

我刚刚发现 github 上有另一个按钮,上面写着“Git Read-only”。它提供了一个类似但略有不同的 URL,它可以工作:

git://github.com/mikehaertl/phpwkhtmltopdf.git

EDIT: As @damick pointed out below the button seems to be gone now. But you can still manually change the original URL to match the pattern shown here.

编辑:正如@damick 指出的,按钮下方现在似乎不见了。但是您仍然可以手动更改原始 URL 以匹配此处显示的模式。

回答by simi

That is most likely because it was trying to use SSH credentials, and with https its not. Therefore when you used

这很可能是因为它试图使用 SSH 凭据,而使用 https 则不是。因此,当您使用

git clone git://github.com/mikehaertl/phpwkhtmltopdf.git

it worked. :D

有效。:D