Rover12421's Blog

The End.

一个多余的操作导致git不能clone

       目前大部分工作都转移到VM里的Mountain Lion的Mac OS上了,但是git库是在真机里,需要clone一份过去,很久没弄了,也忘记应该具体怎么操作了.于是直接给git上传了一个public key,并用管道(cat >>)把key写到了authorized_keys当中.然后测试,发现需要密码.一看到需要密码,那肯定是没弄好.

       翻看了下以前写的blog,想起怎么弄了,登录gitolite的admin,把key加到keys文件夹下,push到库中就OK了.如果用户名不一样,还需要在conf文件中添加上新用户.提交的时候有个警告:

remote: WARNING: keydir/Rover12421.pub duplicates a non-gitolite key, sshd will ignore it

      没管他,意思是已经有相同的key了,估计是我前面手动cat到authorized_keys引起的.测试clone,不成功:
git clone git@192.168.1.222:RsApktool.git
Cloning into 'RsApktool'...
fatal: 'RsApktool.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

      不能读取库,真是郁闷,ssh登录测试,发现还是需要输入密码,测试了好几次,忽然想起是不是手动加key导致的.用vi打开authorized_keys看了下:
ssh-rsa ****** Rover12421@Rover12421s-Mac.local
# gitolite start
command="/Develop/GitServer/bin/gitolite-shell gitmirror",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa ******  git@localhost.localdomain
command="/Develop/GitServer/bin/gitolite-shell rover12421",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa ******  rover12421@Rs-Inspiron-7520
command="/Develop/GitServer/bin/gitolite-shell Rover12421",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa ****** Rover12421@Rover12421s-Mac.local
command="/Develop/GitServer/bin/gitolite-shell server-gitlocal",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa ******  git@Rs-Inspiron-7520
# gitolite end

        发现我手动添加的key在最前面,应该是优先匹配了手动添加的第一条,导致没有执行gitolite-shell命令.于是注释掉第一行的ssh-rsa,测试通过,clone成功:
git clone git@192.168.1.222:RsApktool.git                           
Cloning into 'RsApktool'...
remote: Counting objects: 6158, done.
remote: Compressing objects: 100% (2523/2523), done.
remote: Total 6158 (delta 2840), reused 5630 (delta 2622)
Receiving objects: 100% (6158/6158), 52.21 MiB | 1.53 MiB/s, done.
Resolving deltas: 100% (2840/2840), done.

        

Comments