私有github搭建使用

1.本地安装gitosis 、git

gitosis是git的server端,安装很简单

yum  install git.i686 gitosis.noarch

2.配置gitosis

a) 创建key

[root@localhost tmp]# useradd git
[root@localhost tmp]# su git
[git@localhost tmp]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/git/.ssh/id_rsa): 
Created directory '/home/git/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/git/.ssh/id_rsa.
Your public key has been saved in /home/git/.ssh/id_rsa.pub.
The key fingerprint is:
4f:91:ca:56:14:a5:3c:69:cf:86:64:16:e9:f3:01:95 git@localhost.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
|          +=o.   |
|         oo=E    |
|         .&.     |
|       . Bo*.    |
|        S oo+.   |
|       . o ..    |
|          .      |
|                 |
|                 |
+-----------------+
[git@localhost tmp]$


b)初始化gitosis服务端

[git@localhost ~]$ gitosis-init <~/.ssh/id_rsa.pub
[git@localhost ~]$ ll
total 8
drwxr-xr-x. 2 git git 4096 Jun  3 21:19 gitosis
drwxr-xr-x. 4 git git 4096 Jun  3 21:17 repositories
[git@localhost ~]$ pwd
/home/git
[git@localhost ~]$
repositories是代码仓库,以工程为单位,一个工程一个文件夹


c)添加用户

[git@localhost ~]$ pwd
/home/git
[git@localhost ~]$ mkdir github
[git@localhost ~]$ cd git
bash: cd: git: No such file or directory
[git@localhost ~]$ cd github/
[git@localhost github]$ git clone git@192.168.11.128:gitosis-admin.git
Initialized empty Git repository in /home/git/github/gitosis-admin/.git/
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 17 (delta 4), reused 3 (delta 0)
Receiving objects: 100% (17/17), done.
Resolving deltas: 100% (4/4), done.
[git@localhost github]$ ll
total 4
drwxr-xr-x. 4 git git 4096 Jun  3 23:26 gitosis-admin
[git@localhost github]$ cd gitosis-admin/
[git@localhost gitosis-admin]$ ll
total 8
-rw-rw-r--. 1 git git  176 Jun  3 23:26 gitosis.conf
drwxrwxr-x. 2 git git 4096 Jun  3 23:26 keydir
[git@localhost gitosis-admin]$ cat gitosis.conf #这个里面添加用户的信息
[gitosis]

[group gitosis-admin]
writable = gitosis-admin
members = git@localhost.localdomain hello

[group github]
writable = github
members = git@localhost.localdomain hello
[git@localhost gitosis-admin]$ ll keydir/ #这个里面添加的是ssh-keygen 产生的pubkey
total 8
-rw-rw-r--. 1 git git 407 Jun  3 23:26 git@localhost.localdomain.pub
-rw-rw-r--. 1 git git 409 Jun  3 23:26 hello.pub
[git@localhost gitosis-admin]$ 


注意:keydir 存放的名字是hello.pub 那么 gitosis.conf里面使用的名字同样是hello,两者一定要一致

git的管理员,git这个用户去拉去线上的管理文件,同时修改文件然后提交,这样用户hello就添加完毕了

d)添加工程

[git@localhost ~]$ cd repositories/
[git@localhost repositories]$ pwd
/home/git/repositories
[git@localhost repositories]$ ll
total 8
drwxrwxr-x. 7 git git 4096 Jun  3 21:17 github.git
drwxr-x---. 8 git git 4096 Jun  3 21:19 gitosis-admin.git
[git@localhost repositories]$ mkdir github.git
[git@localhost repositories]$ git init --bare
[git@localhost repositories]$ cd github.git/
[git@localhost github.git]$ ll -a
total 40
drwxrwxr-x.  7 git git 4096 Jun  3 21:17 .
drwxr-xr-x.  4 git git 4096 Jun  3 21:17 ..
drwxrwxr-x.  2 git git 4096 Jun  3 21:17 branches
-rw-rw-r--.  1 git git   66 Jun  3 21:17 config
-rw-rw-r--.  1 git git   73 Jun  3 21:17 description
-rw-rw-r--.  1 git git   23 Jun  3 21:17 HEAD
drwxrwxr-x.  2 git git 4096 Jun  3 23:14 hooks
drwxrwxr-x.  2 git git 4096 Jun  3 21:17 info
drwxrwxr-x. 11 git git 4096 Jun  3 21:28 objects
drwxrwxr-x.  4 git git 4096 Jun  3 21:17 refs
[git@localhost github.git]$ 

添加了又一个github名字的工程,工程添加完成但是还得需要去给这个工程添加用户

具体的方式1.git的管理员拉取admin文件,添加一个group---github,同时在group里面添加usermember----hello;2.然后提交给远端,这样hello这个用户就可以使用github这个工程了


至此,自己搭建的私有github就可以使用了。



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值