openfrontier / docker-gerrit

Build a Docker image with the Gerrit code review system
Apache License 2.0
196 stars 118 forks source link

Replication failed for private gitlab server #123

Open yihongyuelan opened 4 years ago

yihongyuelan commented 4 years ago

I'm running 3.0.4 gerrit in docker, and I got replication fail log as below: Caused by: org.eclipse.jgit.errors.UnsupportedCredentialItem: ssh://git@git.xx.com:22: org.eclipse.jgit.transport.CredentialItem$YesNoType:The authenticity of host 'git.xx.com' can't be established. RSA key fingerprint is 4e:87:0d:3d:c4:4a:5f:21:b5:af:22:99:41:02:de:0d.

replication.config: [remote "git.xx.com"] url = git@git.xx.com:my-group/${name}.git push = +refs/heads/:refs/heads/ push = +refs/tags/:refs/tags/ push = +refs/changes/:refs/changes/ threads = 3 rescheduleDelay = 15 [replication] maxRetries = 1 [gerrit] autoReload = true replicateOnStartup = true

I want to know where to config the ssh keys?I've tried these two options, but replication still failed.

  1. docker exec -it myGerrit /bin/bash and then ssh-keygen -t rsa -C gerrit.admin@xx.com, cat /root/.ssh/id_rsa.pub and add to private gitlab server. Add /root/.ssh/config file: Host git.xx.com: IdentityFile ~/.ssh/id_rsa PreferredAuthentications publickey

Opiton 1 result: Caused by: org.eclipse.jgit.errors.UnsupportedCredentialItem: ssh://git@git.xx.com:22: org.eclipse.jgit.transport.CredentialItem$YesNoType:The authenticity of host 'git.xx.com' can't be established. RSA key fingerprint is 4e:87:0d:3d:c4:4a:5f:21:b5:af:22:99:41:02:de:0d.

  1. docker exec -it myGerrit /bin/bash and then su -s /bin/bash gerrit2, and process ssh-keygen -t rsa -C gerrit.admin@xx.com. cat ~/.ssh/id_rsa.pub and add to private gitlab server. Add /var/gerrit/.ssh/config file (If switch to gerrit2, cd ~ then the home path is /var/gerrit): Host git.xx.com: IdentityFile ~/.ssh/id_rsa PreferredAuthentications publickey

Option2 result: Cannot replicate to git@git.xx.com:my-group/GerritTest.git org.eclipse.jgit.errors.TransportException: git@git.xx.com:my-group/GerritTest.git: Auth fail

If I generate a ssh key, both two options process ssh -T git@git.xx.com success (outputs:elcome to GitLab, gerrit.admin!)

My question is how to config replication plugin for gerrit in docker.

Thanks BR

thinkernel commented 4 years ago

I've never used replicating over ssh. I'm using http instead. However, according to the document. The format of local user's key should be pem. I wounder if this info may helps.

w-huaqiang commented 4 years ago

@yihongyuelan Did you solve it? I also have this problem on k8s