Firstly, getting a git server up and running is pretty easy.
Make sure git is installed
aptitude install git
Create a git user
Change the git user’s shell
echo $(which git-shell) >> /etc/shells, and then
chsh git -s $(which git-shell)
You should now be able to initiate a git repo on your server.
cd ~git && git init --bare my-new-project.git && chown -R git:git my-new-project.git
That’s it! You’ve created a git repo, now on your local machine go and clone it.
git clone git@myserver:my-new-project.git
Security is up to you! I have disable password auth in ssh, and loaded my key into
This is strongly recommended !!! but if you’re building a git server you probably know enough to secure your ssh server. (I hope !)
I’m not going to delve into virtual hosting with Nginx , that’s not in this scope.
What is in scope, is getting nginx to respond accordling to git requests.
I’ve chosen to serve my git repos over https using a pre-defined sub directory (that doesn’t actually exists) called
Grab a copy of the following config, chuck it in the appropriate place in nginx then restart nginx.
Securing http/s with auth
Finally, let’s put a password on the git repo access via http/s.
htpasswd -c /home/git/.htpasswd myusername
Once you’ve done that you should be able to check out your repo using http/s from your local machine.
git clone https://email@example.com/git/my-new-project.git