'Git Submodule - Permission Denied

I am not able to clone the submodule existing within my private git repository. I do have access to entire repository,

Have used the below commands but dint work, please help. What is the right way to clone the submodules in an existing repository?

djrecker$ git submodule update --init --recursive
Submodule 'Path' ([email protected]:Path) registered for path 'App'
Cloning into 'Path'...
Permission denied (publickey).
fatal: Could not read from remote repository.


Solution 1:[1]

I was facing the same issue. The problem was on your github repo , you might be using some old ssh key.

You need to update the current ssh key.

Steps involved are:

1. vim ~/.ssh/id_rsa.pub
2. copy the ssh key
3. Go to the github settings
4. Select the option ssh keys
5. Remove the old ssh keys not used anymore.
6. Add a new ssh key.
7. Try running the "git submodule update --recursive"

This worked for me !!

Solution 2:[2]

  • On Windows:

In my case, it was complaining about the same issue when I was using a regular command line (Git CMD). Then I tried with Git Bash and no issue no more.

Solution 3:[3]

I had this issue. In my case, the public key (~/.ssh/id_rsa.pub) wasn't set up on the server properly.

Ensure you're getting all the submodules:

Reference: Git update submodules recursively

# This must be called twice. Once for new and once for existing submodules.
git submodule update --init --recursive
git submodule update --recursive

To diagnose permission issues with your key:

To check details of your submodules

  • Open .gitmodules in the project root folder and ensure things look okay. As recommended by @VonC try cloning them in a separate folder.
  • You might want to switch submodules from using SSH to HTTPS. That will let you type a username and password. But that can cause issues with your teammates and build automation. Speak to them first.

Solution 4:[4]

In my case the issue was caused by console which did not ask me for a password. Solution was to change the console from CMDER to Gitbash. When I used CMDER it does not show the password window which caused this access denied issue.

Solution 5:[5]

Interestingly, in a similar occasion using the HTTPS link worked for me.

Solution 6:[6]

Had the same problem with TortoiseGit / Windows subsystem for Linux / GitBash. The solution is to use authentication via an agent (key) instead of password.

For TortoiseGit:

  • run Pageant
  • add your key
  • enter password
  • TortoiseGit menu -> submodule update ...

(without pageant git clone it asks for password and works as intended, but git update fails with error)

For WS4L:

$ eval `ssh-agent -s`
$ chmod 600 /path/to/key
$ ssh-add /path/to/key

proceed with git submodule update

Solution 7:[7]

i had created a submodule in error by using git init in a parent folder AND in its subfolder. Just removed the .git folder and started over with git init in the correct parent folder.

Solution 8:[8]

Win10 + git bash terminal in VS Code. In my case, I was using git bash through VS Code. When using submodules, git pops up a window to enter pass phrase for the key. Bash through VSCode would't pop this up. With the windows Context menu item, "Git Bash Here" in the repo folder as shown below: Context menu Screen Grab

git submodule update

works splendidly.

Solution 9:[9]

In my case, the problem occurred when my project was placed in the system catalog (Program Files) despite the fact that the git clone was successful.

Also, this problem was not in the SSH key, this was also okay.

After moving it to folder C:\Users\username it works.

Try it, if you using Windows

Solution 10:[10]

Cloning into '/data_hdd/xxx/3rdparty/deep_graph_libaray'...
xxxmodules/3rdparty/deep_graph_libaray: Permission denied
fatal: clone of 'https://xxx/deep_graph_libaray.git' into submodule path '/xxx/3rdparty/deep_graph_libaray' failed

I meet problem above, I sort it out. Here is my solution:

  1. docker run image -v 3rdparty/ mapping into container.
  2. git submodule add in container.

I think root user can do it.

Solution 11:[11]

I had the same problem. I removed the entry from .gitmodules and executed git submodule init; git submodule update then I removed the entry from the file system and executed git submodule update --remote and it started downloading the submodule again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 arpiagar
Solution 2 Cem.S
Solution 3
Solution 4 ÄŒamo
Solution 5 ang3lkar
Solution 6
Solution 7 doug nelson
Solution 8 Abhinav Tripathi
Solution 9 kirkadev
Solution 10 Luke
Solution 11 Black