I have a git repository A that contains a submodule B. When I execute git submodule update --init --recursive in repository A to update the submodule, I get a Permission denied (publickey) error. The ssh key is correctly added to the remote (gitlab) and I can clone both repositories independently via ssh. Cloning B outside of A works.
Repository B is in the same group as repository A (on gitlab).
I tried the following:
- Setting an absolute reference in the
.gitmodules - Changing the reference in
.gitmodulesto http - Making a clean clone of A
- Adding a fresh ssh key (with and without passphrase)
- Cloning repository A with option
--recursive
How can I solve the problem?
The .gitmodules contains the following content:
[submodule "B"]
path = path_to_B
url= ../B.git
The complete error message:
Cloning into '{path_to_B}'...
git@gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '{git@.../B.git}' into submodule path '{path_to_B}' failed
Failed to clone '{path_to_B}'. Retry scheduled
Cloning into '{path_to_B}'...
git@gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '{git@.../B.git}' into submodule path '{path_to_B}' failed
Failed to clone '{path_to_B}' a second time, aborting