Firstly, getting a git server up and running is pretty easy.
Make sure git is installed aptitude install git
Create a git user adduser git
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
SSH Security
Security is up to you! I have disable password auth in ssh, and loaded my key into ~git/.ssh/authorized_keys
This is strongly recommended !!! but if you’re building a git server you probably know enough to secure your ssh server. (I hope !)
Configuring Nginx
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 git/
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
You’re done!
Once you’ve done that you should be able to check out your repo using http/s from your local machine.
git clone https://myusername@yourdomain.com/git/my-new-project.git
Leave a Comment
Liked what you've read?
It only takes a second of your time, but it means the world to me.
Don't comment on Facebook, comment here !
I don't keep any of your information, I only ask for a name, and an email to stop spammers!
Pretty please !! :)