Problem
When Gerrit want to sync data to Gitlab, "reject HostKey" error message show in replication_log.
org.eclipse.jgit.errors.TransportException: git@10.10.10.10:/var/opt/gitlab/git-data/repositories/gerrit/test_only.git: reject HostKey: 10.10.10.10
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:159)
at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:136)
at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:262)
at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:161)
at com.googlesource.gerrit.plugins.replication.PushOne.listRemote(PushOne.java:503)
at com.googlesource.gerrit.plugins.replication.PushOne.doPushAll(PushOne.java:447)
at com.googlesource.gerrit.plugins.replication.PushOne.generateUpdates(PushOne.java:440)
at com.googlesource.gerrit.plugins.replication.PushOne.pushVia(PushOne.java:392)
at com.googlesource.gerrit.plugins.replication.PushOne.runImpl(PushOne.java:375)
at com.googlesource.gerrit.plugins.replication.PushOne.runPushOperation(PushOne.java:288)
at com.googlesource.gerrit.plugins.replication.PushOne.access$000(PushOne.java:81)
at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:258)
at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:255)
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:255)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:377)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.jcraft.jsch.JSchException: reject HostKey: 10.10.10.10
at com.jcraft.jsch.Session.checkHost(Session.java:791)
at com.jcraft.jsch.Session.connect(Session.java:342)
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
... 24 more
[2016-02-15 12:20:07,234] [] Cancelled 1 replication events during shutdown
Solution
Copy SSH Public Key.
# ssh-keyscan -t rsa 10.10.10.10
Copy this
10.10.10.10 ssh-rsa AAAAB3NzaC1yc2.................EJWmSsyckVod
Add SSH Public Key to known_hosts.
# vim ~/.ssh/known_hosts
Paste here
10.10.10.10 ssh-rsa AAAAB3NzaC1yc2.................EJWmSsyckVod