sofh7777 发表于 2018-9-18 08:54:43

在Linux下使用gitosis配置安装Git服务器

Step 1,准备
  首先,确认你的计算机中装有Git,python,openssh-server,python-setuptools等软件。
  如果是在ubuntu,命令如下:
sudoapt-get installgit openssh-server python2.6 python2.6-setuptoolsStep 2, 生成Key,添加Server
Key的生成
  使用命令sshkeygen,按照他的提示,一步一步生成,即可。(一直安回车的话,会生成一个空密码的key,这个一般情况下会满足大部分需求)
  ssh-keygen -t rsa -C "test.example.com"
  完毕后会在 ~/.ssh/目录下生成id_rsa.pub文件。这个是key'的公钥
安装gitosis
  git clone https://github.com/res0nat0r/gitosis.git
  cd gitosis
python setup.py install添加Server
  创建新的用户,git
  sudo useradd
  将前两步生成的id_rsa.pub复制到git的home目录下,(scp,cp按照情况来)
  输入命令
gitosis-init chmod755/home/git  chmod700/home/git/.ssh
  chmod644/home/git/.ssh/authorized_keys
  这样,就会创建一个默认的gitosis-admin.git版本库
Step 3,管理git服务器
  使用客户端的机器,也就是刚才生成key的机器
git clone git@127.0.0.1:gitosis-admin  就会创建出一个版本库,叫做gitosis-admin
  其中有个gitosis.conf 文件,和keydir目录
  conf文件是配置文件,可以配置用户的权限,keydir目录是用户的公钥存放的目录,以 用户名.pub 的形式存下来
添加一个新用户:
  讲新用户的pub key放入keydir中,命名为XXX.pub,在conf中进行配置
  讲其添加到之前的一个项目组中,或新建个组
writable = gitosis-adminmembers = reyoung@Reyoung例如如上描述的就是,gitosis-admin组,对gitsis-admin版本库可写,成员有reyoung@Reyoung修改完所有配置文件,commit&push即可添加一个新项目
  1、在writeable文件中添加项目名称
  2、在本地初始化项目,示例如下
cd ..  mkdir 项目名
  cd 项目名
  git init
  git remote add origin git@someServer.com:myNewProject.git
3、将本地初始化的项目,提交到Server  touch readme#新建readme是为了避免提交空项目导致报错
  git add .
  # . 表示当前目录的所有文件 提交单个文件直接写文件名,如fish
  git commit -a -m "This is my initial commit for myNewProject"
  #-a 提交单个文件避免使用 -a参数
git push origin master

[*]

页: [1]
查看完整版本: 在Linux下使用gitosis配置安装Git服务器