【问题标题】:Gitlab can't clone repository even though ssh works即使 ssh 工作,Gitlab 也无法克隆存储库
【发布时间】:2020-04-08 02:00:42
【问题描述】:

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

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

git clone ssh://git@domain.de: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.

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

我还检查了我的 SSH 公钥是否工作

ssh git@domain.de -p 1337 -T
Welcome to GitLab, Anonymous!

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

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

【问题讨论】:

  • 认识到这个问题已经过时了,但仍然很有趣——为什么不使用 git clone git@domain.de:project/repository.git 呢? - 这种常见的模式不是一种选择吗?

标签: git ssh gitlab


【解决方案1】:

尝试类似 scp 的语法:

git clone ssh://git@domain.de:1337:project/repository.git

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

但事实证明这是 gitlab 服务器~gitlab/.ssh/authorized_keys 中的 ssh 密钥问题(有点像issue 4730)。
OP Gelix 确认in the comments

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

(而不是Welcome to GitLab, Anonymous!

【讨论】:

  • 以同样的错误结束。为了使用 1337 端口,我在 ssh 配置中创建了一个主机,否则使用 scp 语法默认为 22
  • @Felix 和 ~/.ssh/config,你的 url 会变成(例如,假设一个名为 gitlabHost 条目):gitlab:project/repository.git:这样行吗?
  • 这正是我所做的并导致了同样的错误。 ssh gitlab -T 显示成功消息,所以我认为配置文件中没有拼写错误
  • @Felix GitLab ~/.ssh/authorized_keys 中是否存在某种不一致? (如github.com/gitlabhq/gitlabhq/issues/4730#issuecomment-85232416
【解决方案2】:

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

sudo gitlab-ctl reconfigure

【讨论】:

    猜你喜欢
    • 2019-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-28
    • 1970-01-01
    相关资源
    最近更新 更多