

How to set up your own private Git server on Linux - urbanmbeatz
http://tumblr.intranation.com/post/766290565/how-set-up-your-own-private-git-server-linux

======
qjz
The instructions for adding a public key to the authorized_keys file are a bit
reckless, as they will wipe out any others that exist. Although not universal
(not included with Mac OS X, for example) the ssh-copy-id command is much
preferable. At its most basic:

    
    
      ssh-copy-id example.com
    

Or, to specify a specific key & remote user:

    
    
      ssh-copy-id -i ~/.ssh/id_rsa.pub bob@example.com
    

This will properly append the key, with the bonus of securing the permissions
of the remote user's home, ~/.ssh, and ~/.ssh/authorized_keys.

~~~
lftl
Or...

ssh bob@example.com 'cat >> .ssh/authorized-keys' < ~/.ssh/id_rsa.pub

~~~
davidu
This is not an idempotent operation, and I would not recommend this for
anything besides a one-off event.

~~~
lftl
Interesting, I hadn't thought about it since, for my usage, setting up keys is
pretty much always a one-off event (and pretty rare on top of that). What are
the consequences of dropping your key into authorized_keys files multiple
times? Tried it out on a Debian box, and didn't see any issues other than the
obvious clutter.

~~~
davidu
"looks bad" :-)

But it's a bad habit to get into. Or better yet, it's better to think in
idempotent operations when doing systems work.

------
mechanical_fish
_I decided to move all my private repositories to my own server._

When you do this, make sure that the server has continuous backups. Also, make
sure you still have an offsite backup.

Once you figure out what these things are worth, you may realize that you
should probably just keep paying Github.

~~~
pilif
The backups aren't as important as each git repo is a fully blown code. If
your local repo is destroyed, you still have the server copy. If your server
blows up, you still have the local copy.

There are many other good reasons for a service like Github, like the
excellent collaboration features, the really good repository and history
browser or the good bugtracker.

If you don't need those (small team, working alone) but are concerned about
uploading your intellectual property to a third party server in a potentially
foreign country (depending on your location), then quickly setting up gitosis
/ gitweb / redmine might be enough for you.

In my personal case, I would really love to use github even for my small team,
but I'm too concerned about the legal issues to go ahead with that (and the
local installation is plain too expensive).

~~~
jackowayed
What legal issues/other issues from uploading your code to GitHub are you
worried about?

I can't imagine that GitHub would steal your code. They've never heard of you,
they have no reason to believe your code is worth anything to them, and one "I
have pretty damn good evidence that GitHub stole my code" could ruin their
entire business.

You mentioned legal issues. Are you afraid someone's going to ... subpoena
your code or something? Because if that happens, you'd have to turn it over
anyway.

They've got some pretty intense-looking security[1], and people like Twitter
trust them with their code[2]. If they aren't worried, why are you?

1: <http://help.github.com/security/>

2: I don't know that that's officially known, but I saw Twitter commenting on
the "GitHub now has Organizations" post complaining about the lack of the
cheaper plan that they added the next day. So they definitely have some
private repos on GitHub.

~~~
pilif
I don't live in the US. Our company isn't based in the US. While I'm somewhat
familiar with US legislation by reading HN, I certainly don't feel comfortable
to upload my code to US based servers of a US company as I plainly don't know
their laws well enough to trust them with my companies intellectual property.

Of course, I could always trust them for now and instantly remove my stuff
when there are signs of trouble, but I asked them (a year ago) whether
deletions are instant and irreversible and they told me the usual thing:
repositories are not instantly deleted so they could restore them in case of
accidental deletions. In addition they stay around in backups for an
indefinite time.

Legislation not known well enough and no control over the removal of my code
from their machines - call me paranoid, but these are good reasons not to
upload my code to them.

------
rafd
I highly recommend using Gitosis; it makes managing teams, projects and users
a breeze. It's really nifty: you get a git repo that contains the ssh keys and
config file to manage the system. Add the user's key, add the user to the
config file, push, and you're done!

~~~
cdr
I don't see any reason to run gitosis when there's gitolite, even for a single
user. Either is definitely preferable to doing things manually, though.

~~~
ehsanul
I just went throught gitolite's readme, and I don't see any reason why a lone
dev might want to use it, since it seems to be built for managing teams with
access control needs.

Doing it manually for me just means (on the server):

    
    
          mkdir project_name
          cd project_name
          git init --bare
    

Hardy difficult.

I already have ssh keys set up from long back, so that's all I have to do
really. Then I just add the remote repository on my local machine.

~~~
cdr
I avoid sysadmin work when possible - it's not something I enjoy spending time
on.

Setting up gitolite is dead simple - setting up a git server manually manually
might be 'simple' compared to other tasks, but it's still unnecessary work.
Creating new repos is as simple as changing the config file and pushing it -
no need to do anything on the server at all.

I see absolutely no reason TO do it manually, and that's the decider.

------
ebishop
Earlier this year, I moved from SVN to git when I found I really needed better
branch management. One thing I found is that hosting a git repository is a lot
less straightforward than hosting a subversion repository, particularly since
fewer bug tracking systems have adequate support for DVCS at this point. Trac
seems to be lagging behind Redmine in this regard.

If anyone is interested, I created a library for deploying git hosting (or SVN
hosting if you really prefer) on a VPS with Redmine project management:
<http://github.com/ericpaulbishop/redcloud>

Git hosting is provided via gitosis, not gitolite since there is no redmine
plugin for gitolite support. It runs on Ubuntu VPS and uses Nginx with
passenger compiled in as the web server. PHP via php-fpm can optionally be
compiled in too, in case other sites on the same box need PHP (as is the case
for what I'm doing).

------
lesterbuck
For simple uses, there are several free git hosting services. Assembla offers
unlimited repos and 2GB for free, while ProjectLocker offers unlimited repos
and 500MB for free. There are some limitations on tools and sharing and users,
but for personal use, these can act just like another repo in the cloud, Yet
Another place your private code is copied. No private server maintenance
required.

If you do want your own private server, VPSs are getting ridiculously cheap.
lowendbox.com relays the latest offer of Open VZ 512MB, 20GB of storage, 1TB
of bandwidth, all for ... $3.60/month. At those prices, your backup strategy
could simply be to have two, or three, from different vendors. These cheap VPS
hosts can just disappear one day, so never have this be your only copy of
anything.

------
labria
Another good solution is installing gitorious. Especially if you have a big
team and a few projects.

~~~
e1ven
I ran throught his this week- Gitorious' install is a bit of a pain, and the
software is just BROKEN in places (referencing an array, when the variable is
not in one).

I like the system, and it's very flexible, but it doesn't seem like they treat
it very well for outside use.

~~~
timfreund
I'm working on a VM/ec2 image for Gitorious to ease the installation pain. I'm
working from the the Ubuntu installation script that the Gitorious project
provides, and I will try to get the improvements merged upstream. Things are
mostly working, so I will be making the work public after a few more days of
testing. Feel free to contact me if you'd like more info.

------
kilian
Or, use gitosis and be able to control your repositories and access to them
much, much easier: [http://scie.nti.st/2007/11/14/hosting-git-repositories-
the-e...](http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-
secure-way)

------
thibaut_barrere
In the last few weeks, I've started using this a lot as well, to host my
multiple little "labs" projects without blowing my private github repositories
limit.

I keep private github repos for collaborative projects.

------
parbo
Does git have the equivalent of "hg serve"?

~~~
js4all
That would be git-web. It's not built-in, but a set of Perl scripts that are
invoked via CGI from Apache or similar. Setup is a snap as it can be installed
with apt-get/yum/zypper.

~~~
callahad
Honest question: What's the easiest way for two developers using git to push
and pull from each other, if they're running Windows and on an isolated LAN?

------
nkabbara
Hi Guys,

This is a question I've been struggling with for a while now.

Would you host your company's super important bread and butter code on GitHub
instead of your own server?

I get a funny feeling every time I think about this mostly because I've put
tons of time (3 years) into our code base and I think of it as one of the most
important aspects of our company.

Then again, GitHub hosts their code on GitHub which makes me feel a bit at
ease in doing so.

I would really appreciate your insights.

Thanks!

~~~
xiongchiamiov
I would, and I do. I don't use their wiki or issue tracker, though, so if they
managed to lose the data, it'd take all of 30 seconds to (well, plus pushing
some rather large files) to set it up again.

Our codebase is GPLed, so there are no concerns about privacy.

------
aliguori
You typically want to enable the post-update hook on the server by mv
'${GITDIR}/hooks/post-update.sample' '${GITDIR}/hooks/post-update'.

This makes sure that the repository works with dumb servers which is required
for things like http/cgit.

~~~
labria
.. and chmod +x on it, IIRC

------
bobbywilson0
warehouse makes a nice front-end to your personal git server
<http://github.com/drcapulet/warehouse> "Re-Written from the ground-up for use
with Git"

------
rmk
Why would one need a git server? I am somewhat unclear on this... any good
reads on this topic?

I am using git because I _hate_ svn (so I use git-svn), so I am curious how a
pure git setup would work...

~~~
weaksauce
easier collaboration with others that you need privacy on. A backup of your
repos(though you should have backups on this too). a canonical version of your
repository with read access for your team but commit access for only a select
few.

I am sure there are more scenarios but this is just what I could think of in a
min.

------
jrmxrf
Is there any point in putting obvious things that anyone can google when he
need them on HN main page?

~~~
kqr2
The value is not only in the post but in the subsequent discussion it
generates.

In fact, I will often "cheat" and read the discussion first.

~~~
xiongchiamiov
You must be a recovering slashdotter, like me.

