Add support for direct replication to another Gerrit instance

Currently when replicating to another Gerrit instance replication plugin
requires also system SSH access in order to create, delete and update
HEAD reference of replicated project. For those three operations plugin
will execute system commands over SSH.

When other site of replication is also a Gerrit server we can use its
SSH API to perform operations mentioned above. Then we drop dependency
on system SSH access.

In order to set up a SSH connection between two Gerrit instances, one
must generate ssh-key-pair with empty passphrase. Then this key-pair can
be set to be used for connecting to explicitly configured destination
host.

TEST PLAN:
To test this patch it is recommended to generate new ssh-key-pair and
configure the ssh client like follows:

 * ssh-keygen -f ~/.ssh/empty-passphrase
 * echo "Host localhost\n\tPort 29419\n\tIdentityFile ~/.ssh/empty-passphrase" >> ~/.ssh/config

Then set up a second Gerrit instance (set up sshd to listen on port
29419) which will be the replication destination and create
replication user with public ssh-key from ~/.ssh/empty-passphrase.pub.
On the replication master server etc/replication.config needs to be
adjusted as well:

 [remote "other-gerrit"]
     url = ssh://$replication_user@localhost:29419/${name}.git
     adminUrl = gerrit+ssh://$replication_user@localhost:29419/

After starting both instances creating a project in the master will
result in the same project created on the replication destination.
Of course Gerrit access rights still apply, therefore $replication_user
should have create project capability and push rights.

Change-Id: I677f7bd1164be259916c8cebdd4ddeee469402a3
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
5 files changed
tree: 76898594376e6795d2c9d353e09754de7017f49d
  1. .settings/
  2. src/
  3. .gitignore
  4. .mailmap
  5. BUILD
  6. LICENSE