Cannot access gitolite repos with non-gitolite adm

2019-05-26 16:06发布

问题:

I've installed Gitolite 3.5.3 on Ubuntu 12.04. I created test repo and I can access it over ssh only with gitolite user but not others. I need to allow access other system users (user1,user,user2) or usergroup to git(push, pull merge etc) over ssh like this:

git clone user1@domain.com:megaproject

But I try to connect like this:

git clone user@domain.com:megaproject

and write correct password for this user I get:

fatal: 'megaproject' 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.

Even if I create keydir directory in the home folder of gitolite user with my ssh public key - nothing changes.

What should I change to provide access in such a way?

回答1:

You never clone/access a gitolite-managed repo with a 'user'.
You always use the 'git' account that you used to install gitolite.

Gitolite will then deduce who you actually are by looking for the public key used for this call in the ~git/.ssh/authorized_keys file.

See more at "How do programs like gitolite work?".


If you want to access a gitolite-managed repo as different user, you need to have the right public/private keys for those users, and reference the private key in an ~/.ssh/config file, as shown in "users are asked for password while using gitolite".

Host gitolite_as_user1
    HostName gitolite_server_name
    User git
    IdentityFile ~/.ssh/user1

Host gitolite_as_user2
    HostName gitolite_server_name 
    User git
    IdentityFile ~/.ssh/user2

Note that the ssh url will be:

ssh://gitolite_as_user1:yourRepo
ssh://gitolite_as_user2:yourRepo

And it will always use the 'git' account (but with different public ssh keys)