Gitosis and Gitweb – Part 1 – Setup

Gitosis and Gitweb – Part 1 – Setup



from:http://lostechies.com/jasonmeridth/2010/05/25/gitosis-and-gitweb-part-1-setup/

I’ve had a number of people ask me where they should host their Git repositories. Of course, my default question back is, “Can the code be public or does it need to be private?”. Usually they say, “public”. Therefore, my repsonse is Github.com. If they say, “private” I still say Github.  If they don’t “trust” Github, which they should – click the link, then my response is Gitosis and Gitweb. This is by no means the only solution. I’m aware of other ones like Gitorious. I’ve never used Gitorious.

Back to Gitosis. My personal Gitosis server is a slice at Slicehost.com. You can use an Ubuntu server at home as long as you have remote access. I’ve personally only used Gitosis with an Ubuntu slice, so I don’t know if there are any quirks with other Linux distributions. After setting up a slice (after following the instructions here and here) I am ready to go.

Notice: This post is a combination of scie.nti.st’s gitosis post and Scott Chacon’s Pro Git gitosis section. They are my de facto references. Maybe my own will be now. :)

“Enough talk. Let’s fight” ~Po, Kung Fu Panda

Intall Git

After logging into your box, let’s install Git (if not already installed):

Press enter or type ‘Y’ and press enter and git will be installed. Type the following to confirm:

and you’ll see something like:

Intall python-setuptools

Also install the python-setuptools because we’ll need them (gitosis is written in python):

Press enter or type ‘Y’ and press enter and python-setuptools will be installed.

Download Gitosis

We need to clone the gitosis source locally to install it:

Install Gitosis

Now let’s install it:

Gist. Gitosis is now installed. Next steps are to create git user and handle a file permission on a git hook.

Create Git User

You’ll see something like the following if it is successful

Use local, public ssh key

You need to initially use your public ssh key (id_rsa.pub). If you have one, it will be at $HOME/.ssh/id_rsa.pub and if you have never generated one, you can do so by running the following command (accept the default location and you don’t need to enter a passphrase when prompted):

Now you need to upload it to the server/slice. I usually use the scp (secure copy command):

This will upload the local id_rsa.pub file to the /tmp/ folder on the server. Why there? So that the git user can use it. How is that possible? The folder has permissions of 777 (drwxrwxrwt) meaning everyone has read and write access to it.

Sidenote: SSH Port

If you have your sshd daemon running on a different port other than 22 (which is the default, but I highly suggest changing), then you need to use scp like this:

I believe the “-P” option must be capitalized.

Initialize gitosis-admin repository

On the server, issue the following command to set your public ssh key as the first authorized key of a new gitosis-admin repository:

You will see something like the following:

This means it was successful.

Take note: If you put your id_rsa.pub file in a different location you need to use that instead of /tmp/id_rsa.pub

Change Permissions on post-update hook

You have to set the permissions on the post-update git hook of the gitosis-admin repository so that gitosis-admin can add new repository structures when they are added/removed to/from the gitosis.conf file.

Note: First round of this post, I didn’t make this change. When I added a new project, it failed because this hook didn’t have the right permissions.

Clone gitosis-admin repository

Now we’re going to use Git to administrate this gitosis instance. I think that is pretty ingenius. Let’s clone the gitosis-admin repository locally:

We are now in the gitosis-admin repository folder locally

Two most common errors

FIRST ONE:

it is because you have used a port for SSH other than port 22 (the default). To fix this, you need to edit your .ssh/config file and add the following:

Of course, you need to put in your server hostname and port number (i.e., mydomain.com and 12345)

SECOND ONE:

This has usually hit me because I locked down my /etc/ssh/sshd_config file to only allow in certain users or groups. I have to change the AllowUsers line in my file from:

to

Once I restart the ssh daemon:

Now the git user has access to reach my server/slice via ssh.

The local gitosis-admin repository

You now have a local clone of the gitosis-admin repository. The contents are only a conf file and key directory:

 

Note: before anyone asks, the (master) notation in my prompt is usage of the __git_ps1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值