【问题标题】:Cannot clone from gitlab with SSH无法使用 SSH 从 gitlab 克隆
【发布时间】:2020-09-28 18:32:37
【问题描述】:

我最近在一个 ubuntu 18.04 LTS 实例上安装了 gitlab。我正在尝试从 GitLab 克隆一个 repo。 我的 ssh 配置文件如下:

# ~/.ssh/config
User git
Hostname gitlab.com
IdentityFile ~/.ssh/id_ed25519
TCPKeepAlive yes
IdentitiesOnly yes

我已将 ed25519 公钥添加到 GitLab 中的 SSH 密钥中。当我尝试克隆存储库时,我遇到了这个问题-

$ git clone git@xxxx:root/test-project.git
Cloning into 'test-project'...
kex_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.

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

我做错了什么?我检查了互联网上的几个链接,但我无法弄清楚我做错了什么。

如果我使用 http 而不是 ssh,我可以克隆和推送。

 git clone http://xxxx/root/test-project.git
Cloning into 'test-project'...
warning: You appear to have cloned an empty repository.

为什么 http 可以工作而不是 ssh?

【问题讨论】:

标签: ssh gitlab git-clone


【解决方案1】:

你的 ssh clone 声明错误:git clone username git@example.com:root/test.git

该语句将尝试将名为 username 的存储库克隆到相对于您当前路径 git@example.com:root/test.git 的位置。

你想省略username:

git clone git@example.com:root/test.git

【讨论】:

  • 您也可以通过输入 SSH 来执行此操作:git clone https://username@github.com/username/repository
  • 我正在使用 GitLab 中提到的链接。当我点击克隆时,这是它提供的链接。
【解决方案2】:

另一种方法是使用 sourcetree,它只需单击一下即可为您点击所有 git clone 和更新命令,并且还为您的 repo 和分支提供丰富的图形表示

【讨论】:

    猜你喜欢
    • 2019-05-28
    • 2021-09-09
    • 2021-09-05
    • 2013-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-18
    相关资源
    最近更新 更多