[转] 怎样在Ubuntu上安装Git服务器

原文地址:http://songgz.iteye.com/blog/1166854

 

 

第一步:安装Git和Gitolite 

  1. server> sudo apt-get install git-core  
  2. server> sudo apt-get install gitolite  


第二步:安装ssh-key 
1.安装openssh 

  1. server> sudo apt-get install openssh  


2.在服务器上创建git用户 

  1. server> adduser --system --shell /bin/bash --group git  
  2. server> adduser git ssh  
  3. server> passwd git  


3.在客户端生成ssh-key 

  1. client> ssh-keygen  
  2. Generating public/private rsa key pair.  
  3. Enter file in which to save the key (/home/davem/.ssh/id_rsa):  
  4. Enter passphrase (empty for no passphrase):  
  5. Enter same passphrase again:  
  6. Your identification has been saved in /home/davem/.ssh/id_rsa.  
  7. Your public key has been saved in /home/davem/.ssh/id_rsa.pub.  
  8. The key fingerprint is:  
  9. 61:bf:f5:2d:f6:ed:cd:10:b7:0c:be:5d:4d:8f:a3:0d davem@client  


4.上传公共key到服务器 

  1. client> scp ~/.ssh/id_rsa.pub git@server:/tmp/davem.pub  


5.在服务器上导入公共key 

  1. server> gl-setup /tmp/davem.pub  


第三步配置Gitolite添加用户和git项目 
1.下载配置文件 

  1. client> git clone git@server:gitolite-admin  


2.进入gitolite-admin目录编辑conf/gitolite.conf文件 

  1. client> cd gitolite-admin  
  2. client> sudo nano conf/gitolite.conf  


加入mytest项目,如下 

  1. repo    mytest  
  2.                   RW+     =   @all  


提交更改 

  1. client> git commit -m "Added mytest repo" conf/gitolite.conf  
  2. client> git push  


3.拷贝其他用户的公共key到keydir目录 

  1. client> cp ~/Downloads/another.pub keydir/  


提交更改 

  1. client> git add keydir/another.pub  
  2. client> git commit -m "Added another as a user" keydir/another.pub  
  3. client> git push  


第四步测试 

  1. client> git clone git@server:mytest  


成功!

posted @ 2013-05-25 01:38  DavidHHuan  阅读(257)  评论(0编辑  收藏  举报