SSH用にGerritを設定する
SSHキーの設定
ターゲットリポが既にHelixサーバ内に存在していてはいけません。
ソースリポは、空になっていてはいけません。
-
Git Connectorサーバに
root
ユーザとしてログインします。 .ssh
ディレクトリを作成します。mkdir /var/www/.ssh
- ディレクトリの所有者を
web-service-user
に割り当てます。chown web-service-user:gconn-auth /var/www/.ssh
-
ユーザを
root
からweb-service-user
に切り替えます。Ubuntu CentOS su -s /bin/bash - www-data
su -s /bin/bash - apache
Git ConnectorインスタンスのパブリックSSHキーとプライベートSSHキーを生成します。
ssh-keygen -t rsa -b 4096 -C web-service-user@gitConnector.com
プロンプトに従います。
- パブリックキーを検索します。
/var/www/.ssh/id_rsa.pub
- このパブリックキーをGerritサーバにコピーして、
/var/www/.ssh/id_rsa.pub
を、ミラーリング用にクローンおよびフェッチを実行するユーザアカウント(helix-user)に追加します。 - ミラーリング用にWebhookを設定します。
- 環境変数
GCONN_CONFIG
をgconn.conf
ファイルへの絶対パスに設定します。export GCONN_CONFIG=/opt/perforce/git-connector/gconn.conf
- Webhookを追加します。
gconn --mirrorhooks add graphDepotName/repoName ssh://helix-user@GerritHost.com/repoName.git
- 環境変数
-
--mirrorhooks
コマンドで生成するsecretトークンを保存します。ヒントsecretトークンも
/opt/perforce/git-connector/repos/graphDepotName/repoName.git/.mirror.config
に保存されます。
Gerritサーバでの処理
GERRIT_SITE/git/repoName/configファイルのGerritリポジトリの構成ファイルを更新します。
この場合、GERRIT_SITEは、使用するGerritサーバのルートディレクトリです。
[gconn]
mirror-url = https://GitConnector.com/mirrorhooks
token = <secret_token from /opt/perforce/git-connector/repos/graphDepot/repoName.git/.mirror.config>
git-ssh-url = <upstream_url from /opt/perforce/git-connector/repos/graphDepot/repoName.git/.mirror.config>
[gconn "http"]
sslverify = false
次の手順