3 navsection: installguide
4 title: Install the Git server
7 Copyright (C) The Arvados Authors. All rights reserved.
9 SPDX-License-Identifier: CC-BY-SA-3.0
12 # "Introduction":#introduction
13 # "Install dependencies":#dependencies
14 # "Create "git" user and storage directory":#create
15 # "Install gitolite":#gitolite
16 # "Configure gitolite":#config-gitolite
17 # "Configure git synchronization":#sync
18 # "Update config.yml":#update-config
19 # "Update nginx configuration":#update-nginx
20 # "Install arvados-git-httpd package":#install-packages
21 # "Restart the API server and controller":#restart-api
22 # "Confirm working installation":#confirm-working
24 h2(#introduction). Introduction
26 Arvados support for git repository management enables using Arvados permissions to control access to git repositories. Users can create their own private and public git repositories and share them with others.
28 The git hosting setup involves three components.
29 * The "arvados-git-sync.rb" script polls the API server for the current list of repositories, creates bare repositories, and updates the local permission cache used by gitolite.
30 * Gitolite provides SSH access. Users authenticate by SSH keys.
31 * arvados-git-http provides HTTPS access. Users authenticate by Arvados tokens.
33 Git services must be installed on the same host as the Arvados Rails API server.
35 h2(#dependencies). Install dependencies
37 h3. Alma/CentOS/Red Hat/Rocky
40 <pre><code># <span class="userinput">dnf install git perl-Data-Dumper openssh-server</span>
47 <pre><code># <span class="userinput">apt-get --no-install-recommends install git openssh-server</span>
51 h2(#create). Create "git" user and storage directory
53 Gitolite and some additional scripts will be installed in @/var/lib/arvados/git@, which means hosted repository data will be stored in @/var/lib/arvados/git/repositories@. If you choose to install gitolite in a different location, make sure to update the @git_repositories_dir@ entry in your API server's @application.yml@ file accordingly: for example, if you install gitolite at @/data/gitolite@ then your @git_repositories_dir@ will be @/data/gitolite/repositories@.
55 A new UNIX account called "git" will own the files. This makes git URLs look familiar to users (<code>git@[...]:username/reponame.git</code>).
57 On Debian- or Red Hat-based systems:
60 <pre><code>gitserver:~$ <span class="userinput">sudo mkdir -p /var/lib/arvados/git</span>
61 gitserver:~$ <span class="userinput">sudo useradd --comment git --home-dir /var/lib/arvados/git git</span>
62 gitserver:~$ <span class="userinput">sudo chown -R git:git ~git</span>
66 The git user needs its own SSH key. (It must be able to run <code>ssh git@localhost</code> from scripts.)
69 <pre><code>gitserver:~$ <span class="userinput">sudo -u git -i bash</span>
70 git@gitserver:~$ <span class="userinput">ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa</span>
71 git@gitserver:~$ <span class="userinput">cp .ssh/id_rsa.pub .ssh/authorized_keys</span>
72 git@gitserver:~$ <span class="userinput">ssh -o stricthostkeychecking=no localhost cat .ssh/id_rsa.pub</span>
73 Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
74 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7aBIDAAgMQN16Pg6eHmvc+D+6TljwCGr4YGUBphSdVb25UyBCeAEgzqRiqy0IjQR2BLtSirXr+1SJAcQfBgI/jwR7FG+YIzJ4ND9JFEfcpq20FvWnMMQ6XD3y3xrZ1/h/RdBNwy4QCqjiXuxDpDB7VNP9/oeAzoATPZGhqjPfNS+RRVEQpC6BzZdsR+S838E53URguBOf9yrPwdHvosZn7VC0akeWQerHqaBIpSfDMtaM4+9s1Gdsz0iP85rtj/6U/K/XOuv2CZsuVZZ52nu3soHnEX2nx2IaXMS3L8Z+lfOXB2T6EaJgXF7Z9ME5K1tx9TSNTRcYCiKztXLNLSbp git@gitserver
75 git@gitserver:~$ <span class="userinput">rm .ssh/authorized_keys</span>
79 h2(#gitolite). Install gitolite
81 Check "https://github.com/sitaramc/gitolite/tags":https://github.com/sitaramc/gitolite/tags for the latest stable version. This guide was tested with @v3.6.11@. _Versions below 3.0 are missing some features needed by Arvados, and should not be used._
83 Download and install the version you selected.
86 <pre><code>$ <span class="userinput">sudo -u git -i bash</span>
87 git@gitserver:~$ <span class="userinput">echo 'PATH=$HOME/bin:$PATH' >.profile</span>
88 git@gitserver:~$ <span class="userinput">. .profile</span>
89 git@gitserver:~$ <span class="userinput">git clone --branch <b>v3.6.11</b> https://github.com/sitaramc/gitolite</span>
91 Note: checking out '5d24ae666bfd2fa9093d67c840eb8d686992083f'.
93 git@gitserver:~$ <span class="userinput">mkdir bin</span>
94 git@gitserver:~$ <span class="userinput">gitolite/install -ln ~git/bin</span>
95 git@gitserver:~$ <span class="userinput">bin/gitolite setup -pk .ssh/id_rsa.pub</span>
96 Initialized empty Git repository in /var/lib/arvados/git/repositories/gitolite-admin.git/
97 Initialized empty Git repository in /var/lib/arvados/git/repositories/testing.git/
98 WARNING: /var/lib/arvados/git/.ssh/authorized_keys missing; creating a new one
99 (this is normal on a brand new install)
103 _If this didn't go well, more detail about installing gitolite, and information about how it works, can be found on the "gitolite home page":http://gitolite.com/._
105 Clone the gitolite-admin repository. The arvados-git-sync.rb script works by editing the files in this working directory and pushing them to gitolite. Here we make sure "git push" won't produce any errors or warnings.
108 <pre><code>git@gitserver:~$ <span class="userinput">git clone git@localhost:gitolite-admin</span>
109 Cloning into 'gitolite-admin'...
110 remote: Counting objects: 6, done.
111 remote: Compressing objects: 100% (4/4), done.
112 remote: Total 6 (delta 0), reused 0 (delta 0)
113 Receiving objects: 100% (6/6), done.
114 Checking connectivity... done.
115 git@gitserver:~$ <span class="userinput">cd gitolite-admin</span>
116 git@gitserver:~/gitolite-admin$ <span class="userinput">git config user.email arvados</span>
117 git@gitserver:~/gitolite-admin$ <span class="userinput">git config user.name arvados</span>
118 git@gitserver:~/gitolite-admin$ <span class="userinput">git config push.default simple</span>
119 git@gitserver:~/gitolite-admin$ <span class="userinput">git push</span>
120 Everything up-to-date
124 h2(#config-gitolite). Configure gitolite
126 Configure gitolite to look up a repository name like @username/reponame.git@ and find the appropriate bare repository storage directory.
128 Add the following lines to the top of @~git/.gitolite.rc@:
131 <pre><code><span class="userinput">my $repo_aliases;
132 my $aliases_src = "$ENV{HOME}/.gitolite/arvadosaliases.pl";
133 if ($ENV{HOME} && (-e $aliases_src)) {
134 $repo_aliases = do $aliases_src;
136 $repo_aliases ||= {};
140 Add the following lines inside the section that begins @%RC = (@:
143 <pre><code><span class="userinput"> REPO_ALIASES => $repo_aliases,
147 Inside that section, adjust the 'UMASK' setting to @022@, to ensure the API server has permission to read repositories:
150 <pre><code> UMASK => <span class="userinput">022</span>,
154 Uncomment the 'Alias' line in the section that begins @ENABLE => [@:
157 <pre><code><span class="userinput"> # access a repo by another (possibly legacy) name
162 h2(#sync). Configure git synchronization
164 Create a configuration file @/var/www/arvados-api/current/config/arvados-clients.yml@ using the following template, filling in the appropriate values for your system.
165 * For @arvados_api_token@, use @SystemRootToken@
166 * For @gitolite_arvados_git_user_key@, provide the public key you generated above, i.e., the contents of @~git/.ssh/id_rsa.pub@.
169 <pre><code>production:
170 gitolite_url: /var/lib/arvados/git/repositories/gitolite-admin.git
171 gitolite_tmp: /var/lib/arvados/git
172 arvados_api_host: <span class="userinput">ClusterID.example.com</span>
173 arvados_api_token: "<span class="userinput">zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz</span>"
174 arvados_api_host_insecure: <span class="userinput">false</span>
175 gitolite_arvados_git_user_key: "<span class="userinput">ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7aBIDAAgMQN16Pg6eHmvc+D+6TljwCGr4YGUBphSdVb25UyBCeAEgzqRiqy0IjQR2BLtSirXr+1SJAcQfBgI/jwR7FG+YIzJ4ND9JFEfcpq20FvWnMMQ6XD3y3xrZ1/h/RdBNwy4QCqjiXuxDpDB7VNP9/oeAzoATPZGhqjPfNS+RRVEQpC6BzZdsR+S838E53URguBOf9yrPwdHvosZn7VC0akeWQerHqaBIpSfDMtaM4+9s1Gdsz0iP85rtj/6U/K/XOuv2CZsuVZZ52nu3soHnEX2nx2IaXMS3L8Z+lfOXB2T6EaJgXF7Z9ME5K1tx9TSNTRcYCiKztXLNLSbp git@gitserver</span>"
180 $ sudo chown git:git /var/www/arvados-api/current/config/arvados-clients.yml
181 $ sudo chmod og-rwx /var/www/arvados-api/current/config/arvados-clients.yml
184 h3. Test configuration
186 notextile. <pre><code>$ <span class="userinput">sudo -u git -i bash -c 'cd /var/www/arvados-api/current && bin/bundle exec script/arvados-git-sync.rb production'</span></code></pre>
188 h3. Enable the synchronization script
190 The API server package includes a script that retrieves the current set of repository names and permissions from the API, writes them to @arvadosaliases.pl@ in a format usable by gitolite, and triggers gitolite hooks which create new empty repositories if needed. This script should run every 2 to 5 minutes.
192 Create @/etc/cron.d/arvados-git-sync@ with the following content:
195 <pre><code><span class="userinput">*/5 * * * * git cd /var/www/arvados-api/current && bin/bundle exec script/arvados-git-sync.rb production</span>
199 h2(#update-config). Update config.yml
201 Edit the cluster config at @config.yml@ .
204 <pre><code> Services:
206 ExternalURL: "<span class="userinput">ssh://git@git.ClusterID.example.com</span>"
208 ExternalURL: <span class="userinput">https://git.ClusterID.example.com/</span>
210 "http://localhost:9001": {}
212 GitCommand: <span class="userinput">/var/lib/arvados/git/gitolite/src/gitolite-shell</span>
213 GitoliteHome: <span class="userinput">/var/lib/arvados/git</span>
214 Repositories: <span class="userinput">/var/lib/arvados/git/repositories</span>
218 h2(#update-nginx). Update nginx configuration
220 Use a text editor to create a new file @/etc/nginx/conf.d/arvados-git.conf@ with the following configuration. Options that need attention are marked in <span class="userinput">red</span>.
223 <pre><code>upstream arvados-git-httpd {
224 server 127.0.0.1:<span class="userinput">9001</span>;
228 server_name git.<span class="userinput">ClusterID.example.com</span>;
229 proxy_connect_timeout 90s;
230 proxy_read_timeout 300s;
232 ssl_certificate <span class="userinput">/YOUR/PATH/TO/cert.pem</span>;
233 ssl_certificate_key <span class="userinput">/YOUR/PATH/TO/cert.key</span>;
235 # The server needs to accept potentially large refpacks from push clients.
236 client_max_body_size 128m;
239 proxy_pass http://arvados-git-httpd;
245 h2(#install-packages). Install the arvados-git-httpd package
247 The arvados-git-httpd package provides HTTP access, using Arvados authentication tokens instead of passwords. It must be installed on the system where your git repositories are stored.
249 h3. Alma/CentOS/Red Hat/Rocky
252 <pre><code># <span class="userinput">dnf install arvados-git-httpd</span>
256 h3. Debian and Ubuntu
259 <pre><code># <span class="userinput">apt-get --no-install-recommends install arvados-git-httpd</span>
263 h2(#restart-api). Restart the API server and controller
265 After adding Workbench to the Services section, make sure the cluster config file is up to date on the API server host, and restart the API server and controller processes to ensure the changes are applied.
268 <pre><code># <span class="userinput">systemctl restart nginx arvados-controller</span>
272 h2(#confirm-working). Confirm working installation
274 Create 'testrepo' in the Arvados database.
277 <pre><code>~$ <span class="userinput">arv --format=uuid repository create --repository '{"name":"myusername/testrepo"}'</span>
278 </code></pre></notextile>
280 The arvados-git-sync cron job will notice the new repository record and create a repository on disk. Because it is on a timer (default 5 minutes) you may have to wait a minute or two for it to show up.
284 Before you do this, go to Workbench and choose *SSH Keys* from the menu, and upload your public key. Arvados uses the public key to identify you when you access the git repo.
287 <pre><code>~$ <span class="userinput">git clone git@git.ClusterID.example.com:username/testrepo.git</span>
293 Set up git credential helpers as described in "install shell server":install-shell-server.html#config-git for the git command to use your API token instead of prompting you for a username and password.
296 <pre><code>~$ <span class="userinput">git clone https://git.ClusterID.example.com/username/testrepo.git</span>