Server Side:
First a git user has to be made, this can be done with the commands:
# Create a gitadmin group to manage git server
# Make a new system user 'git' with a home directory and
# set the shell to the restricted git-shell
sudo useradd git -rm -s $(which git-shell)
sudo passwd git
# Allow git admins to changes config files
sudo chgrp -R gitadmin /home/git
# Create a public git folder for git and gitadmin to use/manage
sudo mkdir /srv/git/
sudo chown git /srv/git/
sudo chgrp gitadmin /srv/git/
To access the git server through SSH you have to make an an allowed_keys file. This can be done with the following:
# Make the .ssh and allowed keys file
mkdir /home/git/.ssh
touch /home/git/.ssh/allowed_keys
# Change permissions of ssh files
chmod 700 /home/git/.ssh && chmod 600 /home/git/.ssh/allowed_keys
# Add your public key
sudo runuser -u git "echo <your-ssh-pubkey> >> /home/git/.ssh/allowed_keys"
From there you can add script commands into your /home/git
folder to manipulate and manage repositories and access to your git server through SSH.