This is an old revision of the document!
Configure the machine that will be running the git server first. In order, this requires creating the git user, and then creating the .ssh directory and authorized keys files, and then establishing appropriate permissions.
sudo adduser git su - git cd ~ mkdir .ssh && chmod 700 .ssh touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
You can add keys to authorized keys file using copy and paste, or using some bash syntax (from within the git user's shell) as follows:
cat /tmp/id_rsa.john.pub >> ~/.ssh/authorized_keys
Now, let's finish configuring the server.
cd /srv mkdir git cd git/ mkdir repositoryname.git cd repositoryname.git/ git init --bare --shared
The shared option above allows more than just the git user to write to the repository. The users must have permissions to do so, however, so since the directories were created by the git user, one can add the user to the git group. If you need this functionality, then on the server, make sure to execute the following command for each user:
sudo adduser <username> git
The instructions below assume the clients are on the same LAN and using a directory in their home directory dedicated to git repos. If the clients are not on the same LAN, then use openvpn to tunnel into the LAN.
cd ~ mkdir git cd git/ git clone git@gitserver:/srv/git/repositoryname.git git clone git@gitserver:/media/sexa/Stores/Zion/zion.git cd repositoryname/ nano README git commit -am"added a line to README for repository participants" git push origin master
This method has everyone using the user git in order to clone the repository, and unless tweaked will allow users shell access to the server. To stop shell access, simply add :/bin/false to the end of the git user's entry in /etc/passwd. Using other user names for access / cloning will be covered in a later tutorial. Set the new origin as master:
git remote set-url origin ssh://sexa@10.28.88.2:/srv/zion.git git remote set-url origin ssh://sexa@10.28.88.2:/media/sexa/Stores/Zion/zion.git
The restricted shell for git user may need to be restored to normal log in shell for certain repository servers.
git:x:1001:1001:,,,:/var/opt/gitlab:/bin/sh