git 即使 ssh 有效,Gitlab 也无法克隆存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33837103/
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-19 11:32:19  来源:igfitidea点击:

Gitlab can't clone repository even though ssh works

gitsshgitlab

提问by Felix

As the title states, I can't clone a repository from a Gitlab 6 server even though the ssh seems to work.

正如标题所述,即使 ssh 似乎可以工作,我也无法从 Gitlab 6 服务器克隆存储库。

When trying to clone, it looks like this:

尝试克隆时,它看起来像这样:

git clone ssh://[email protected]:1337/project/repository.git
Cloning into 'repository'...
Access denied.
fatal: Could not read from remote repository.

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

In the project, I have the role of "developer" which should have the rights to clone a repository?

在项目中,我扮演“开发者”的角色,应该有权克隆存储库?

I also checked if my SSH public key is working

我还检查了我的 SSH 公钥是否有效

ssh [email protected] -p 1337 -T
Welcome to GitLab, Anonymous!

More irritating to me is that for a friend of mine seems everything to work fine.

更让我恼火的是,对于我的一个朋友来说,似乎一切正常。

Edit:The main indicator for the problem stated here is the greeting from the SSH Test. In an working enviroment it should be greeting you with your name instead Anonymous!

编辑:此处所述问题的主要指标是来自 SSH 测试的问候语。在工作环境中,它应该用你的名字而不是匿名来问候你!

采纳答案by VonC

Try the scp-like syntax:

尝试类似 scp 的语法:

git clone ssh://[email protected]:1337:project/repository.git

That forces the use of ~/.ssh/configactually, which means the url can be simplified to gitlab:project/repositoriy.git.

这实际上强制使用~/.ssh/config,这意味着可以将 url 简化为gitlab:project/repositoriy.git.

But it turned out to be an ssh key issue in the gitlab server ~gitlab/.ssh/authorized_keys(a bit like in issue 4730).
The OP Gelixconfirms in the comments:

但结果证明是 gitlab 服务器中的 ssh 密钥问题~gitlab/.ssh/authorized_keys(有点像issue 4730)。
OP Gelix确认的评论

I removed my key from Gitlab, manually from authorized_keys, readded it on Gitlab. Everything fine now.
Message with SSH Test is now also Welcome to GitLab, Felix *****!

我从 Gitlab 中手动删除了我的密钥authorized_keys,然后在 Gitlab 上读取了它。现在一切都很好。
带有 SSH 测试的消息现在也是Welcome to GitLab, Felix *****

(instead of Welcome to GitLab, Anonymous!)

(而不是Welcome to GitLab, Anonymous!

回答by hablema

I had the same problem recently with my private GitLab-CE hosted server. Reconfiguring the GitLab saved me. I have tried editing the local config file and adding the host also, but it didn't work. This worked for me.

我最近在我的私人 GitLab-CE 托管服务器上遇到了同样的问题。重新配置 GitLab 拯救了我。我曾尝试编辑本地配置文件并添加主机,但没有奏效。这对我有用。

sudo gitlab-ctl reconfigure