Configure Gerrit for SSH
Prerequisites
The target repo must NOT already exist in P4 Server.
The source repo must not be empty.
Set up the SSH keys
-
On the Git Connector server, log in as the
rootuser. - Create a
.sshdirectory:mkdir /var/www/.ssh - Assign the owner of the directory to be he web service user for your platform:
chown web-service-user:gconn-auth /var/www/.sshwhere the web-service-user is either www-data for Ubuntu or apache for CentOS.
-
Switch user from
rootto the web service user for your platform:Ubuntu CentOS su -s /bin/bash - www-datasu -s /bin/bash - apacheand generate the public and private SSH keys for the Git Connector instance:
ssh-keygen -t rsa -b 4096 -C web-service-user@gitConnector.comwhere the web-service-user is either www-data for Ubuntu or apache for CentOS.
then follow the prompts.
-
Locate the public key:
/var/www/.ssh/id_rsa.pub -
Copy this public key to the Gerrit server and add
/var/www/.ssh/id_rsa.pubto the user account (p4-user) that performs clone and fetch for mirroring. - Configure the webhook for mirroring:
- Set the environment variable
GCONN_CONFIGto the absolute path to thegconn.conffile:export GCONN_CONFIG=/opt/perforce/git-connector/gconn.conf - Add the web hook:
gconn --mirrorhooks add graphDepotName/repoName ssh://p4-user@GerritHost.com/repoName.git
- Set the environment variable
-
Save the secret token that the
--mirrorhookscommand generates.
The secret token is also included in the repo spec on the P4 Server. To write the repo spec to standard output, run:
p4 repo -o {//graphDepotName/repoName}
On the Gerrit server
Update the configuration file for the Gerrit repository in the GERRIT_SITE/git/repoName/config-file,
where GERRIT_SITE represents the root directory of your Gerrit server.
[gconn]
mirror-url = https://GitConnector.com/mirrorhooks
token = secret-token-from-repo-spec (p4 repo -o {//graphDepot/repoName})
git-ssh-url = upstream-url-from-repo-spec (p4 repo -o {//graph_depot/repo_name})
[gconn "http"]
sslverify = false