Console Login

Escaping SVN Hell: Building a Private Git Server on CentOS 5

Escaping SVN Hell: Building a Private Git Server on CentOS 5

I still wake up in a cold sweat thinking about my last Subversion merge conflict. It was 2007, the deadline was an hour away, and the central SVN server decided to lock the database. We lost four hours of work. If you are managing a distributed team across Oslo and Kyiv, relying on a centralized, single-point-of-failure version control system is professional suicide.

Enter Git. Linus Torvalds built it to manage the Linux kernel, and frankly, it is the only viable option for serious development in 2009. While services like GitHub are popping up, sending your proprietary source code to a US-hosted cloud is a risk many Norwegian enterprises cannot take. You need to own the metal your code lives on.

Here is how to set up a bulletproof, private Git server on a CoolVDS instance running CentOS 5.3, keeping your intellectual property safe under Norwegian privacy laws.

Why Shared Hosting Kills Git

I have seen developers try to run Git repositories on cheap shared hosting accounts. It works fine until you run git gc (garbage collection) or a large team pushes simultaneously. Git is efficient, but it is memory-hungry when compressing objects.

On a shared host, your process gets killed for using too much RAM. On a proper VPS, you have dedicated resources. Specifically, at CoolVDS, we use Xen virtualization. Unlike OpenVZ, Xen guarantees your RAM is yours. If you pay for 512MB, you get 512MB. No "burst" marketing lies. For a Git server, this stability is non-negotiable.

The Setup: CentOS 5 & SSH

We are going to use the SSH protocol. It is standard, secure, and you likely already have the keys generated. No complex heavy HTTP WebDAV configurations, just raw speed.

1. Install Git Core

First, update your repositories. If you are on a fresh CoolVDS node, the mirrors are local, so this flies.

[root@server ~]# yum update -y
[root@server ~]# yum install git-core

Note: If git-core isn't in your base repo, grab the EPEL (Extra Packages for Enterprise Linux) rpm.

2. Create the Git User

Security 101: Never run services as root. We create a dedicated user that will own the repositories.

[root@server ~]# useradd -m -d /home/git -s /bin/bash git
[root@server ~]# passwd git

3. The "Authorized Keys" Strategy

We don't want password prompts every time we push code. Gather the id_rsa.pub keys from your developers.

[root@server ~]# su - git
[git@server ~]$ mkdir .ssh
[git@server ~]$ chmod 700 .ssh
[git@server ~]$ touch .ssh/authorized_keys
[git@server ~]$ chmod 600 .ssh/authorized_keys

Paste your team's public keys into that authorized_keys file, one per line.

4. Initialize the Bare Repository

This is where the magic happens. A "bare" repository has no working directory; it is just the database. Perfect for a central hub.

[git@server ~]$ mkdir project.git
[git@server ~]$ cd project.git
[git@server project.git]$ git --bare init

Latency and The "Speed of Light" Problem

If your developers are sitting in Oslo and your server is in Texas, every git fetch is a lesson in patience. Latency kills flow.

By hosting on VPS Norway infrastructure, you are slashing ping times to single digits for Nordic teams. Furthermore, CoolVDS utilizes enterprise-grade 15k RPM SAS RAID-10 arrays. While SSDs are starting to appear in the consumer market, for server reliability and write endurance in 2009, high-speed SAS is still the king of the datacenter. This ensures that when 10 developers push at once, the disk I/O queue doesn't choke.

Pro Tip: Add Compression no to your local SSH config for the host if you have a slow CPU but fast bandwidth. However, with the Xeon CPUs we use, standard compression usually speeds things up.

Data Sovereignty and Datatilsynet

We cannot ignore the legal landscape. The US Patriot Act allows American agencies to inspect data hosted on US servers. By keeping your repository in Norway, you are protected by the Personopplysningsloven (Personal Data Act). Your data stays between you and the Datatilsynet (Data Inspectorate), not a foreign intelligence agency.

Final Thoughts

Stop using email to send tarballs. Stop using Subversion. Set up a private Git node. It takes 10 minutes, and it gives you total control over your source code.

For a setup like this, you don't need a massive server. A basic CoolVDS instance with 512MB RAM and our low-latency connection to NIX (Norwegian Internet Exchange) is more than enough to handle a team of 20 developers. Keep your code safe, keep it fast, and keep it in Norway.

Ready to migrate? Deploy a CoolVDS CentOS instance today and get your repo live before lunch.