git - Gerrit 无法克隆

标签 git gerrit

我正在尝试创建一个 gerrit 审查系统,并且能够成功地让 gerrit 在端口 8084 上运行,审查正在 29429 端口上成功进行。

当我尝试运行 git clone ssh://user@ip:29429/myrepo.git 时,出现以下错误:

Cloning into 'myrepo'...
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 1024 a1:bc:b8:fe:e7:79:c9:34:96:28:7d:6f:d3:3d:af:9b
Connection abandoned.
fatal: Could not read from remote repository.

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

当我运行 ssh -p 29429 user@ip gerrit ls-projects 它要求我输入我的密码。当我输入密码时 我能够看到 myrepo

以下也可以(确保用户对 gerrit 没问题)

$ ssh -p 29429 user@ip
Enter passphrase:

输入密码后得到以下信息

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

Hi user, you have successfully connected over SSH.

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

git clone ssh://user@ipaddress:29429/REPOSITORY_NAME.git

Connection to ip closed.

请帮忙看看是哪里出错了。我做错了什么或遗漏了什么吗?

最佳答案

问题出在 Putty 和连接端口 (29429) 上。事情是两点。

Gist 1:如果您将私钥和公钥留在 windows 的 .ssh 文件夹中,那么当您执行 ssh -p 29429 user@ip 时,它会询问密码并给您欢迎使用 gerrit 代码审查消息。

第 2 点。克隆时,如果出现“服务器的主机 key 未缓存在注册表中等”- 连接被放弃。 fatal: Could not read from remote repository.”这是由于 putty 未连接到该端口造成的。

要解决此问题,请在该特定端口 (29429) 上登录 putty,然后接受主机 key (基本上在 pop 窗口中单击"is")。您需要在这里了解它不会让您登录(这完全没问题)。这只是缓存服务器 key 。

您可能想要删除 ~/.ssh/known_hosts,然后尝试 ssh user@ip 并登录,在客户端(Windows 机器)上的 .ssh 文件夹中创建 known_hosts 文件。但这不是它正在寻找的地方。 Putty 正在其他地方缓存它(我不知道在哪里,但它不在这里)

然后让您的 putty paegent 保持运行 - 加载您的私钥。然后尝试在 git bash 中克隆。这应该没问题。还要确保Putty Key gen生成的公钥放在Gerrit - settings - ssh keys

如果您遇到权限被拒绝(公钥)的异常,请检查您的 gerrit 用户名,它可能为空或无效(与您的 git 配置设置不同)。

请确保您在运行 git config --global --edit 时(名称和电子邮件 ID 应与您的 gerrit 设置匹配)。

关于git - Gerrit 无法克隆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16606549/

相关文章:

email - Gerrit 不发送电子邮件

c# - 如何在不提交源代码的情况下将数据库凭据获取到 C# 应用程序中?

git - Gerrit :! [远程拒绝] HEAD -> refs/publish/master(无新变化)

git push -> 仅代码审查当前更改(remote.origin.push 覆盖 push.default)

git - 我如何摆脱我的 git repo 中的大包文件?

git - Jenkins 无法连接到 gerrit 存储库(Windows 安装)

gerrit - gerrit 中的 refs/for/refs/* 有什么用?

git - gh-pages d-构建 : failed at deploy script

Git LFS 要求每个跟踪文件的密码

python - 运行 setup.py 时更改包名称