这里一共涉及3个用户
git/drv/bob
git用户是 git专用账户,为git服务器创建
drv用户是 git管理员账户
bob用户是一般用户,与drv在同一实机的不同用户
IP: 10.25.24.245
以下的操作步骤都是来源于网络,主要的操作步骤
//安装一些必要软件
drv@drv:~$ sudo apt-get install openssh-server openssh-client
drv@drv:~$ sudo apt-get install git
//生成drv用户的密钥,将公钥放到/tmp,以便git用户获取
drv@drv:~$ ssh-keygen -t rsa -C HF
drv@drv:~$ cp .ssh/id_rsa.pub /tmp/drv.pub
//创建git用户,并从drv切换到git,然后安装gitolite
drv@drv:~$ sudo adduser --system --shell /bin/bash --gecos 'Git SCM User' --group --disabled-password --home /home/git git
drv@drv:~$ sudo su git
git@drv:~$ git clone http://github.com/sitaramc/gitolite
git@drv:~$ mkdir -p ${HOME}/bin
git@drv:~$ ${HOME}/gitolite/install -to ${HOME}/bin
git@drv:~$ ${HOME}/bin/gitolite setup -pk /tmp/drv.pub
//drv用户 克隆 gitolite-admin.git,并添加foo工程,权限为所有人都可访问,提交
drv@drv:~$ git clone git@drv:gitolite-admin.git
drv@drv:~/gitolite-admin$ vim conf/gitolite.conf
++++++++++++++++++++++++++
repo foo
RW+ = @all
++++++++++++++++++++++++++
......
......
drv@drv:~/gitolite-admin$ git push origin master
//drv用户正常获取自己创建的foo.git
drv@drv:~/rd/2-test-foo$ git clone git@10.25.24.245:foo.git
Cloning into 'foo'...
The authenticity of host '10.25.24.245 (10.25.24.245)' can't be established.
ECDSA key fingerprint is 50:3e:17:82:67:e3:19:aa:84:13:e8:d5:6c:66:96:97.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.25.24.245' (ECDSA) to the list of known hosts.
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
drv@drv:~/rd/2-test-foo$ ls
foo
添加bob用户
=======================================================
//在bob用户生成密钥
bob@drv:~$ ssh-keygen -f .ssh/bob -t rsa -C keypair_bob
//将bob的公钥,用管理员用户drv提交到/gitolite-admin/keydir中
drv@drv:~/gitolite-admin$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: keydir/bob.pub
......
......
drv@drv:~/gitolite-admin$ git push origin master
//在bob用户中下载,下载失败
bob@drv:~/rd/foo_test$ git clone git@10.25.24.245:foo.git
Cloning into 'foo'...
git@10.25.24.245's password:
Permission denied, please try again.
git@10.25.24.245's password:
Permission denied, please try again.
git@10.25.24.245's password:
Permission denied (publickey,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
疑问:
在创建git用户的时候并没有设置密码,为什么git clone的时候提示要密码
已经将bob用户在gitolite中添加,为什么还是不能下载
不知道各位大虾能不能发现什么错误原因,在此先谢谢。
3 个解决方案
#1
没有人帮助吗?
#2
具体怎么操作记不清了,好像是在一个文件里设置每个 project 的权限
#3
我是在这个文件设置权限的 conf/gitolite.conf
#1
没有人帮助吗?
#2
具体怎么操作记不清了,好像是在一个文件里设置每个 project 的权限
#3
我是在这个文件设置权限的 conf/gitolite.conf