Permission denied for specific git path

I need to clone a submodule from the gerrit server into my local project. Here is the .gitmodule file that works:

[submodule "blah/blah/thing"] path = blah/blah/thing url = ssh:// my_username@gerrit.somewhere.com /some-thing.git 

Here is the .gitmodule file that I would like to work because it works for other team members:

 [submodule "blah/blah/thing"] path = blah/blah/thing url = gerrit.somewhere.com:some-thing.git 

When I try to use the latter form, I get this error:

 $ git submodule update --init --recursive Submodule 'blah/blah/thing' (gerrit.somewhere.com:some-thing.git) registered for path 'blah/blah/thing' Cloning into 'blah/blah/thing'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Clone of 'gerrit.somewhere.com:some-thing.git' into submodule path 'blah/blah/thing' failed 

What's wrong?

+4
source share
2 answers

Do not put your username in a .gitmodule file. This will force all users to try and get the submodule using your username. Instead, follow the format in the second example and specify your username in the .ssh/config file:

 Host gerrit.somewhere.com User my_username 

(assuming you are using ssh, which looks like this. If you are also using https, take a look at the .netrc file).

+3
source

I suspect that you are not logged in as the same user. Try

 url = my_username@gerrit.somewhere.com :some-thing.git 

where my_username matches your ssh: URL.

0
source

Source: https://habr.com/ru/post/1485513/


All Articles