Subscribe to NotarySojac's debian career        RSS Feed

Private (secret) Git Servers for your Source Code

Icon Leave Comment
So let's say you have a project that is so hawt, that you literally can't afford to let your trusty ISP see what you're working on. I know everyone loves and trusts names like Comcast, and AT&T to do the right thing in every circumstance, no matter what, but that's beside the point. Sometimes the project you're working on simply _feels_ so epic that it deludes you into a reality where you are the very k-raddist of the k-rad, and everyone else... is out to get your lucky charms. You want CAPITAL_SECRECY. Well, that's not technically possible if you're connected to the internet for extended periods of time with a private source operating system or are using a piece of networking gear with unverified origins (*cough* ebay *cough* 50% discounted Cisco equipment *cough* smelled a bit like solder when you first got it *cough*), but hey, let's just pretend that everything is hunky~dory in that department... and you are super-duper spy secret agent man!

You've probably already been looking at git for version control since you like to keep in touch with the latest trends in order to either benefit from them or ridicule their egregious flaws (if not see here).

For codesharing with git, the goto response is "github" of course. Well, your central repository doesn't _need_ to be publicly available as an open source project at In fact, it can be furtively tucked away at! So let's get started!

There are two methods. You only need to worry about the SSH method because the git protocol method is buggy and actually won't work if you're pushing from a windows machine. Since I intend to move cshrp code, that method does me absolutely no good what so ever.


:::::::::The SSH protocol method:::::::::
The SSH protocol method is less buggy on windows machines, but is less efficient over the network (negligable over LAN).

My first step was to init the git repos for my C# code on my windows machine. Then I initialized "bare" repositories on my linux machine. Bare repositories are the only kind of repos that will accept push requests. They don't have a working directory. That means, to get the files out, you just clone the repository.

To setup a bare repository on my git server, I did...
$  mkdir my_project_folder; cd my_project_folder
$  git --bare init

Then on my windows client, in my code folder, I did...

$  git init
$  git remote add origin ssh://[email protected]/home/USER/dev/cshrp/my_project_folder
$  git add .
$  git commit -m "initial commit"
$  git push -u origin master

From there you can do the usual $ git push and of course $ git pull as you always could with github, only under this setup you may need to type your password to your personal "git server" for the user name USER.

You can also clone to a second windows computer by...

$  git clone ssh://[email protected]/home/USER/dev/cshrp/my_project_folder

The only problem is that right now, it will probably ask you for your password. That's annoying, but you can git rid of it by adding an entry to your .ssh/config file.

(client computer's ~/.ssh/config)
Host servers_cute_name
IdentityFile /home/USER/.ssh/servers_cute_name_rsa

And don't forget to make that key on the client and transfer it over to your server.
# create the rsa key pair
$  ssh-keygen -t rsa -b 2048

# transfer the public key to the server which will put it in it's authorized_keys file for that user
$  ssh-copy-id -i /path/to/ [email protected]_ip
# Supply the password for the server

You can read about the git daemon protocol below if you'd like:

0 Comments On This Entry


Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry