Git server is not but the SSH server and the same Git app used on the client-side.
It is strongly recommended to use SSH-Keys while using SSH especially if it is protecting the source codes of the company.
If you have any doubt read the post Setting Up SSH Keys [Link].
Preparing the environment:
sudo apt update && sudo apt upgrade -y sudo apt install git -y sudo adduser git
Change to the new account:
su git cd ~ mkdir .ssh touch .ssh/authorized_keys chmod 700 .ssh chmod 600 .ssh/authorized_keys
Copy the public keys (/home/user1/.ssh/id_rsa.pub) from all the users that will be allowed to work with the repositories to the file /home/git/.ssh/authorized_keys each one in a different line.
At this point follow the post to Increasing Security with Fail2Ban [Link] to protect the SSH against password brute force attacks.
Create the repositories inside the server:
ssh git@server git init --bare repository1.git exit
Clone the remote repository to local:
git clone git@server:repository1.git
Create a file and pull it to the server:
touch README.md git add . git config --global user.email "[email protected]" git config --global user.name "Your Name" git commit -m "First Pull" git push origin master
The lines in gray will only be used on the very first time.
BONUS
Automate Git operations in multiple repos simultaneously with MyRepos [Link]. For example, pull the all at once:
sudo apt install myrepos -y cd repositoryDirectory mr register mr run git pull
Read more about Working with GitHub Repositories [Link].