Setting Up Git Server Using Gitosis

来源:互联网 发布:python sys.stdin用法 编辑:程序博客网 时间:2024/06/05 03:10

Gitosis is a software for hosting git repositories witten by Tommi Virtanen. It manages multiple repositories under the same user account. It uses SSH public keys to identify users. Users do not need shell accounts on the git server. The operations are done under the shared account.

One benefit we can get from gitosis is that we can give different suers different write/read rights over different repositories. Another benefit is easier user and repository management. The management is done by a special repository named gitosis-admin.git on the server.

Let’s look at how to set up a git server using gitosis. Here we want to set up a git server on example.org. Please refer to Managing Repositories on Git Server Using Gitosis for how to manage and use the repositories managed by gitosis.

Install git and gitosis on server

First , logon to the git server by “ssh username@example.org”. username is the account name that can sudo or the user who knows root’s password to use su on the git server.

Then install gitos and git. On fedora system the command is like this:

$ sudo yum install git gitosis

or

$ su -c 'yum install git gitosis'

The command may be different on the other platforms.

Create server side git user and home

We need to create a Linux account for the shared account. It is usually git. But any account name can be used. The repositories are stored in git’s home directory.

Logon to the git server by ssh username@example.org. username is the account name that can sudo or the one that knows root’s password on the git server.

$ sudo useradd -m -d /home/git -u 1005 git

Here we assume git’s home directory is /home/git.

Setup gitosis management repository

First create the administrator’s SSH public key if you haven’t got one. On the administrator’s local machine:

$ ssh-keygen -t rsa

Then copy it to the git server’s /tmp/ directory:

$ scp ~/.ssh/id_rsa.pub username@example.org:/tmp/id_rsa.pub

Logon to the git server with account that has privilege to sudo or su. Then:

$ sudo su - git$ cd$ gitosis-init < /tmp/id_rsa.pub

Now we have created the gitosis administration repository on git server. The default repository directory is ~/repositories/ under git’s home directory.

Then the administrator can get the gitosis-admin repository from the git server on local machine:

$ git clone git@example.org:gitosis-admin.git

There are one configuration file and one directory in gitosis-admin:

gitosis.conf  keydir

gitosis.conf is the configuration file for gitosis. keydir is used to store the users’ public SSH keys. These files are used to manage repositories and users by the administrator. A git server has been set up by now. Management work can be done by editing the files in the gitosis-admin repository and pushing it to the git server.

Public access

We may want to  give everyone read-only access to a public project without using SSH keys. We can use git-daemon. It is a daemon tool independent of gitosis and it comes with git itself.

First logon to the git server as privileged user, and then use this command to export all the repositories to public users.:

$ sudo -u git git-daemon --base-path=/home/git/repositories/ --export-all

Someone can then clone repository example.git like this:

$ git clone git://example.org/example.git

If we only want to export selected repositories, we should remove “–export-all” from the above command. Then if we want to export example.git to the others, we need to logon the git server (privileged account is needed) and go to the repository’s directory (/home/git/repositories/example.git for this example). Then create a file named git-daemon-export-ok:

$ touch git-daemon-export-ok

Then this repository is exported to the public now, while the others are keep private.


原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 破腹产后肚子硬怎么办 在月子里同房了怎么办 胃变大凸出来了怎么办 坐完月子脊背疼怎么办 月子过后脊背疼该怎么办 怀孕的时候牙疼怎么办 练瑜伽后弯腰疼怎么办 练完瑜伽腰椎疼怎么办 瑜伽开髋动作受伤怎么办 才学瑜伽教培上课紧张怎么办 瑜伽馆不给退费怎么办 脚运动后酸痛该怎么办 婴儿误吞拉链头怎么办 肠功能蠕动慢便秘怎么办 胃肠型和蠕动波怎么办 胃不蠕动了怎么办偏方 喂母乳母亲奶头裂开怎么办 给宝宝吃奶被吃到奶头裂开怎么办 宝宝吃奶奶头裂开了怎么办 小孩吃奶奶头裂开了怎么办 站久坐久腰酸痛怎么办 孕39周胎儿头小怎么办 怀孕腰两侧长肉怎么办 怀孕四个月半月吃点就饱怎么办啊 怀孕四个月睡眠不好怎么办 二胎七个月肚子太大怎么办 上火牙疼牙龈肿怎么办 孕30周乳房胀痛怎么办 怀孕长妊娠纹了怎么办 坐久了肚子胀疼怎么办 怀孕后胖的太快怎么办 怀孕牙齿全坏了怎么办 怀孕脸胖了好多怎么办 孕晚期不爱吃肉怎么办 怀孕期间胖了怎么办啊 孕期长得太胖怎么办 狗吃马肉脸肿了怎么办 狗过敏了脸肿了怎么办 孕初期外阴很痒怎么办 怀孕了吃了田鸡怎么办 孕妇睡眠质量差怎么办吃什么