简体   繁体   English

git clone ssh 权限被拒绝

[英]git clone ssh permission denied

I followed the instruction at https://help.github.com/articles/generating-ssh-keys and typing我按照https://help.github.com/articles/generating-ssh-keys 上的说明进行操作并输入

ssh -T git@github.com

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).我在~/.ssh/id_rsa (RSA) (k2 和 k3)中看到 3 个密钥,其中一个附加了我的电子邮件地址 (k1),另外 2 个附加了我的电子邮件地址。 the key k3 is the same of k1密钥 k3 与 k1 相同

if I type如果我输入

ssh -vT git@github.com

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

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.检查密钥和令牌是否按照 GitHub 提供的说明正确设置。 If I were you, start from scratch again.如果我是你,重新开始。 May be you haven't properly initialized SSH keys with Github -可能是您没有使用 Github 正确初始化 SSH 密钥 -

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

or you can use the shorter scp-like syntax for SSH protocol:或者您可以对 SSH 协议使用更短的类似 scp 的语法:

$ 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 -

在此处输入图片说明

git clone ssh://github.com/username/repository.git is wrong. git clone ssh://github.com/username/repository.git是错误的。 You should be doing:你应该这样做:

git clone ssh://git@github.com/username/repository.git

or better yet:或者更好:

git clone git@github.com:username/repository.git

如果它是一个公共存储库,则可以通过使用带有 fetch url 的 git 协议来避免整个密钥的事情。

git clone git://github.com/username/repository.git

--------- SOLUTION FOR WINDOWS USERS ------------------ --------- WINDOWS 用户解决方案 ------------------

Was facing the same problem in windows, solved as below:在windows下遇到同样的问题,解决方法如下:

after successfully setting up private/public key for git you need to naviagte to :为 git 成功设置私钥/公钥后,您需要导航到:

C:\\Program Files\\Git\\etc\\ssh C:\\Program Files\\Git\\etc\\ssh

-- open ssh-config file present under it and add below information : -- 打开它下面的 ssh-config 文件并添加以下信息:

Host github.com
User git
IdentityFile << absolute path to your private key for git >>

-- restart power shell and try to clone repository again -- 重新启动 power shell 并再次尝试克隆存储库

 git clone  <<url copied from git repo>>

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

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