I am using gerrit for code review and I use, replication plugin to keep the repo in sync with github.com .
But, the replication is not working. It throws me error:
[2014-01-16 11:23:04,694] ERROR com.googlesource.gerrit.plugins.replication.ReplicationQueue : Cannot replicate to [email protected]:visitvinoth/gerrit_prj_1.git
org.eclipse.jgit.errors.TransportException: [email protected]:visitvinoth/gerrit_prj_1.git: reject HostKey: github.com
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:142)
at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248)
at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
at com.googlesource.gerrit.plugins.replication.PushOne.listRemote(PushOne.java:468)
at com.googlesource.gerrit.plugins.replication.PushOne.doPushAll(PushOne.java:416)
at com.googlesource.gerrit.plugins.replication.PushOne.generateUpdates(PushOne.java:409)
at com.googlesource.gerrit.plugins.replication.PushOne.pushVia(PushOne.java:357)
at com.googlesource.gerrit.plugins.replication.PushOne.runImpl(PushOne.java:340)
at com.googlesource.gerrit.plugins.replication.PushOne.runPushOperation(PushOne.java:267)
at com.googlesource.gerrit.plugins.replication.PushOne.access$000(PushOne.java:78)
at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:240)
at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:237)
at com.google.gerrit.server.util.RequestScopePropagator$5.call(RequestScopePropagator.java:222)
at com.google.gerrit.server.util.RequestScopePropagator$4.call(RequestScopePropagator.java:201)
at com.google.gerrit.server.git.PerThreadRequestScope$Propagator$1.call(PerThreadRequestScope.java:75)
at com.googlesource.gerrit.plugins.replication.PushOne.run(PushOne.java:237)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:360)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: com.jcraft.jsch.JSchException: reject HostKey: github.com
at com.jcraft.jsch.Session.checkHost(Session.java:780)
at com.jcraft.jsch.Session.connect(Session.java:342)
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
... 25 more
I have already registered the RSA key of the gerrit user in github.com on my account.
When I try triggering the replicate command manually,
ssh -p 29412 [email protected] gerrit replicate gerrit_prj_1
I get the error,
gerrit: replicate: not found
Please help
If you have access to the gerrit server, you can use StephenKing's answer, and add a ~/.ssh/config file which will specify where are the key to use:
Host github.com
User git
IdentityFile /path/to/the/private/key
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
But if you used default id_rsa and id_rsa.pub (which should have been picked up by ssh), then check on that same Gerrit server the value of $HOME, as I mention in a previous answer.
As StephenKing mentions in the comments:
The part of the error message to helps identifying the problem is rejected HostKey:
github.com.
If ssh doesn't find valid id_rsa(.pub) in $HOME/.ssh, then it looks for a ~/.ssh/config file with a "github.com" entry in it which would tell ssh where to find the right ssh key to connect to the server represented by "github.com".
The issue was:
Since I started gerrit with sudo, it was running as root. now I changes and it works fine
So if the keys were registered in a user HOME, they weren't visible by a process launched by root.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With