我正在尝试连接到我的 VPS 上托管的 gerrit。我在 Windows 上使用 Git Bash。我在 GitBash 中使用 ssh-keygen 生成了 SSH key ,并在 gerrit 服务器上添加了 key 。
当我运行时 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 key ,这次我为 SSH key 添加了密码。我也在 SSH 服务器上添加了该 key 。通常,当 key 附加密码时,Git Bash 终端应该要求密码来解锁私钥。
现在发生的事情是,如果我通过运行命令
ssh -p 29418 <username>@<gerrit-server>
SSH gerrit 服务器它要求我解锁密码,这意味着它使用正确的 ssh key 并显示 Gerrit 欢迎消息问题是当我运行上面列出的 git clone 命令时它不要求密码,这意味着它使用其他一些SSH key ,这就是为什么我得到 SSH_exchange_identification
来自 Gerrit 的错误。在克隆之前我还需要执行任何其他步骤吗?我是否必须进行任何 Git 设置才能成功克隆 Git 存储库?
最佳答案
配置你的 git 设置 -> config
添加 user.name
和 email
(在您的 gerrit 设置中使用)
关于git - 无法克隆 Gerrit 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29047181/