Migrating my old git server (on Ubuntu 18.04 LTS) to a new one (on Ubuntu 20.04 LTS), I switched to gitolite3 to manage server authentication. This post explains how.

Refs: https://gitolite.com/gitolite/migr.html and https://gitolite.com/gitolite/basic-admin#appendix-1-bringing-existing-repos-into-gitolite

First, gitolite3 was installed using:

sudo apt install gitolite3
(with administrator's key left blank) and configured with:
sudo dpkg-reconfigure gitolite3
where:
System user name for gitolite: gituser
Repository path: /var/lib/gitolite3
Finally, I copied my public key into /var/lib/gitolite3/.ssh/authorized_keys to give me access to admin SSH authentication to my git server.

Once done, I simply hard copied all bare repository on my old server in the directory /var/lib/gitolite3/repositories of the new server (except for the repository gitolite-admin for which I kept the one installed by gitolite configuration). I also made sure that all copied repositories have the proper owner on the new server:

sudo chown gituser:gituser -R *
(from within /var/lib/gitolite3/repositories).

Then I ran:

su gituser
gitolite compile
gitolite setup --hooks-only
gitolite trigger POST_COMPILE

The last step of the installation was made from my local computer. I first configured the domain name gitolite.mydomain.org to point to my new git server (with the proper addition in /etc/hosts and locally cloned the new admin

git clone gituser@gitolite.mydomain.org:gitolite-admin
In this directory, I then edited the file conf/gitolite.conf to add all repositories and user rights and I added in keydir the corresponding users' keys. Then I pushed that to my new server.

The last step simply consists in asking all users to edit the file .git/config in their repositories to replace the old server URL by gituser@gitolite.mydomain.org.