git clone ssh 权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23766153/
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
git clone ssh permission denied
提问by gabboshow
I followed the instruction at https://help.github.com/articles/generating-ssh-keysand typing
我按照https://help.github.com/articles/generate-ssh-keys 上的说明进行操作 并输入
ssh -T [email protected]
I get the message
我收到消息
Hi username! You've successfully authenticated, but GitHub does not
# provide shell access.
When I try to clone a repository using ssh
当我尝试使用 ssh 克隆存储库时
git clone ssh://github.com/username/repository.git
I get
我得到
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
If I type
如果我输入
ssh-add -l
I see 3 keys one attached with my email address (k1) and other 2 inside ~/.ssh/id_rsa (RSA)
(k2 and k3).
the key k3 is the same of k1
我看到 3 个键,一个附有我的电子邮件地址 (k1),另外 2 个在里面~/.ssh/id_rsa (RSA)
(k2 和 k3)。密钥 k3 与 k1 相同
if I type
如果我输入
ssh -vT [email protected]
everything is fine...the only line that makes me thinking is
一切都很好......让我思考的唯一一句话是
debug1: Remote protocol version 2.0, remote software version libssh-0.6.0
debug1: no match: libssh-0.6.0
回答by raurora
This terribly nondescript error means that the server rejected your connection. Github has a very rich documentation this -
这个非常难以描述的错误意味着服务器拒绝了您的连接。Github 有一个非常丰富的文档——
https://help.github.com/articles/error-permission-denied-publickey
https://help.github.com/articles/error-permission-denied-publickey
Update -
更新 -
Check if the keys and token are setup properly as per the instructions provided by GitHub. If I were you, start from scratch again. May be you haven't properly initialized SSH keys with Github -
检查密钥和令牌是否按照 GitHub 提供的说明正确设置。如果我是你,重新开始。可能是您没有使用 Github 正确初始化 SSH 密钥 -
cd ~/.ssh && ssh-keygen
cat id_rsa.pub
cd ~/.ssh && ssh-keygen
cat id_rsa.pub
and copy the key into the SSH settings of the Github website.
并将密钥复制到 Github 网站的 SSH 设置中。
To clone a Git repository over SSH, you specify ssh:// URL like this:
要通过 SSH 克隆 Git 存储库,请指定 ssh:// URL,如下所示:
$ git clone ssh://user@server/project.git
$ git clone ssh://user@server/project.git
or you can use the shorter scp-like syntax for SSH protocol:
或者您可以对 SSH 协议使用更短的类似 scp 的语法:
$ git clone user@server:project.git
$ git clone user@server:project.git
Just wanted to make sure you're copying a correct SSH clone URL from your Github account -
只是想确保您从 Github 帐户复制了正确的 SSH 克隆 URL -
回答by manojlds
git clone ssh://github.com/username/repository.git
is wrong. You should be doing:
git clone ssh://github.com/username/repository.git
是错的。你应该这样做:
git clone ssh://[email protected]/username/repository.git
or better yet:
或者更好:
git clone [email protected]:username/repository.git
回答by NOYB
If it is a public repository the whole keys thing can be avoided by using the git protocol with the fetch url.
如果它是一个公共存储库,则可以通过使用带有 fetch url 的 git 协议来避免整个密钥的事情。
git clone git://github.com/username/repository.git