无法克隆 Gerrit 存储库

问题描述 投票:0回答:3

我正在尝试连接到我的 VPS 上托管的 gerrit。我正在使用 Windows 版 Git Bash。我在 GitBash 中使用 ssh-keygen 生成了 SSH 密钥,并在 gerrit 服务器上添加了密钥。 当我运行

ssh -p 29418 <username>@<gerrit-server>
时,我会看到下面的欢迎消息

  ****    Welcome to Gerrit Code Review    ****

  Hi Full Name, you have successfully connected over SSH.

  Unfortunately, interactive shells are disabled.
  To clone a hosted Git repository, use:

  git clone ssh://username@<gerrit-server>:29418/REPOSITORY_NAME.git

但是当我通过运行以下命令克隆存储库时

git clone ssh://<username>@<gerrit-server>:29418/project-name.git

我在 Git Bash 终端中看到以下错误

Cloning into 'project-name'...
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.

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

我无法理解发生了什么以及如何在我的机器中成功克隆我的项目。有人可以帮我解决这个问题吗?

更新1:

我仍然无法弄清楚问题是什么,但我只想分享一些现在正在发生的奇怪的事情。我创建了另一个 SSH 密钥,这次我为 SSH 密钥添加了密码。我也在 SSH 服务器上添加了该密钥。通常,当密钥附加有密码时,Git Bash 终端应要求输入密码来解锁私钥。
现在发生的情况是,如果我通过运行命令 ssh gerrit 服务器

ssh -p 29418 <username>@<gerrit-server>
它会要求我解锁密码,这意味着它使用正确的 ssh 密钥并显示 Gerrit 欢迎消息
问题是它不询问对于当我运行上面列出的 git clone 命令时的密码,这意味着它使用其他一些 SSH 密钥,这就是我从 Gerrit 收到
SSH_exchange_identification
错误的原因。在克隆之前我还需要执行其他步骤吗?我是否需要进行任何 Git 设置才能成功克隆 Git 存储库?

git gerrit git-bash
3个回答
0
投票

配置你的 git 设置 -> config

添加

user.name
email
(在您的 gerrit 设置中使用)


0
投票

我也面临同样的问题,它不适用于最新版本的 Git。

对于 git 版本 - 2.29.3,它对我来说工作得很好。

如果您想确定正在使用哪个 ssh 密钥,请尝试在 .ssh 文件夹中添加一个名为 config 的文件,并包含以下内容。这将帮助您识别正在使用哪个 ssh 密钥 -

# Gerrit 
Host gerrit.*.com
   host gerrit.*.com
   user user_name
   PreferredAuthentications publickey
   IdentityFile ~/.ssh/id_rsa

0
投票

我也有同样的问题。
当我跑步

ssh -p 29418 <username>@<gerrit-server> gerrit ls-projects
时, 我将看到项目列表,但是当我克隆存储库时,我看到相同的错误。
我没有找到原因,但我终于可以从gerrit克隆存储库了。
路径是:gerrit->设置->HTTP Credentials->生成新密码->复制它。
然后转到本地 shell,使用 http 进行 git 克隆存储库,而不是使用 ssh。
当询问您密码时,将刚刚复制的字符串粘贴到 gerrit 上。
希望我可以帮助一些人!

© www.soinside.com 2019 - 2024. All rights reserved.