New Repo Setup
sudo -u git git init --bare /opt/git/{{path}}/{{repo}}.git
git add remote origin git@forge:{{path}}/{{repo}}
Backups
sudo -u git \
tar \
--create \
--zstd \
--directory /opt/git/ \
--file /opt/git/backup/$(date -Is)_forge.tar.zst \
--exclude-dir backup \
.
Server Setup
sudo mkdir -p /opt/git
sudo chown -R git:git /opt/git
sudo adduser --system --shell /usr/bin/git-shell --group --home /opt/git git
sudo apt-get install -y git
sudo -u git mkdir -p /opt/git/.ssh /opt/git/backup
sudo -u git chmod 700 /opt/git/.ssh
sudo -u git touch /opt/git/.ssh/authorized_keys
sudo -u git chmod 600 /opt/git/.ssh/authorized_keys
sudo -u git git config --global init.defaultBranch main
Update /etc/ssh/sshd_config
Match User git
AllowAgentForwarding no
PermitTTY no
X11Forwarding no
sudo systemctl reload sshd
Remaining setup work
- Setup authorized keys in
/opt/git/.ssh/authorized_keys - Extract backup repos and/or upate repo dirs
Client setup
Host forge
Hostname 192.168.32.24
User git