3

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 git@github.com:visitvinoth/gerrit_prj_1.git
org.eclipse.jgit.errors.TransportException: git@github.com: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 vinoth@xxx.xxx.xx.xx gerrit replicate gerrit_prj_1

I get the error,

gerrit: replicate: not found

Please help

StephenKing
  • 36,187
  • 11
  • 83
  • 112
Virtual
  • 2,111
  • 5
  • 17
  • 27
  • 3
    You try to trigger the replication with the wrong command. See the [documentation](https://review.typo3.org/plugins/replication/Documentation/cmd-start.html). The correct syntax is: `ssh -p 29418 review.example.com replication start`. – StephenKing Jan 16 '14 at 07:19
  • @StephenKing, Thanks. Your command works. – Virtual Jan 16 '14 at 07:29

1 Answers1

2

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Ah, I was just about to write the same :-). This solution should help and the problem is that your ssh client (in the context of the Gerrit user) does not yet accept the key of github.com (you can solve this my getting it into the `known_hosts` file, or by disabling host key checking as shown by VonC. – StephenKing Jan 16 '14 at 07:18
  • The part of the error message to helps identifying the problem is `rejected HostKey: github.com`. – StephenKing Jan 16 '14 at 07:20
  • @StephenKing yes, I have edited the answer to better explain why. – VonC Jan 16 '14 at 07:28
  • What should be permission level for ~/.ssh/config ? 777 ? I have added the file. Should i give my user_name for User in that file ? I tried that also. Still I am facing the same error. – Virtual Jan 16 '14 at 07:37
  • @Virtual never 7 on the last bit. Check the all permission issue with http://stackoverflow.com/a/13428529/6309. For `config`, `chmod 600` should be enough – VonC Jan 16 '14 at 07:41
  • @VonC, Thanks. But still I don't see it working. I am getting the same "reject HostKey: github.com" . I don't understand, what I miss. – Virtual Jan 16 '14 at 08:12
  • 1
    @Virtual did you check what user is executing your gerrit process? Is HOME correctly set for that user? Are all parent folders (/, /home/ /home/xxx) protected against write for group (chmod 755 only)? – VonC Jan 16 '14 at 08:24
  • @VonC, Thanks. replication started working. Since I started gerrit with sudo, it was running as root. now I changes and it works fine. Facing another problem now. Posted a new question for that. http://stackoverflow.com/questions/21159160/gerrit-remote-rejected-head-refs-for-master-internal-server-error – Virtual Jan 16 '14 at 10:29
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/45363/discussion-between-virtual-and-vonc) – Virtual Jan 16 '14 at 10:45