git, raspberrypi

Host your own git repository at home

While Github is a great way of sharing your project and cooperating with others, often times you would like to have stuff such as your code or configuration files under version control.

You can setup a Gitlab service at home if you want to be in control of your central repository, but unless you are going to be colaborating with a team it can be an overkill and somewhat time consuming to install and configure.

I like having my private config files and scripts at home in my Raspberry Pi, so that I can synchronize my configurations, aliases and scripts between my desktop, laptop, other raspberries and my PC at work. Github allows private repos, but why would I share details about my systems, users and networks with a third party?

Once you have this setup in place, you can even automate backups of your configuration using etckeeper.

Basic overview

Setting up a private git repository is almost too simple.

  1. Log in into your Raspberry Pi.
  2. Install the git package
  3. Create a git user

That’s it! You can now create a bare repository in your Pi, owned by the git user

And access it from outside. Say your hostname, IP or domain for your Raspberry Pi is server

Final setup

Of course this is a bit too simple. We want a little extra security.

If you haven’t already, generate the SSH keys for the device that you want to access the repo

Register your public key with the git repository

, which is equivalent to

Disable login sessions and password for git user, so only users in authorized_keys can access

Finally, use git-shell for the user git as a limited shell for git operations only.

That’s it! You now have a secure, self-hosted git repository. Easy!

Author: nachoparker

Humbly sharing things that I find useful [ github dockerhub ]

2 Comments on “Host your own git repository at home

Leave a Reply

Your email address will not be published. Required fields are marked *