Git Submodule - Permission Denied
Solution 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
- 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
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:
- Access: Ensure that either: (1) you're cloning a public repo or (2) it's private, but your github account has access.
- Diagnose with
ssh -vT [email protected]
. Ensure the key you set up is listed there. For more help on permissions issues, follow this guide: https://help.github.com/articles/error-permission-denied-publickey/ - Adding a key to Github: https://help.github.com/articles/generating-ssh-keys/
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
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
Interestingly, in a similar occasion using the HTTPS link worked for me.
Related videos on Youtube
Max
Updated on July 09, 2022Comments
-
Max almost 2 years
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.
-
VonC over 9 yearsCan you clone
[email protected]:Path
independently? Just to check that a direct clone would work and that you do have access. -
Max over 9 yearsYes i did that and i get the entire repo except the submodule,
-
VonC over 9 yearsCan you check the
.gitmodules
content (in the repo you just cloned), and try cloning the url referenced in it. -
Max over 9 yearsCan you please tell me how do i do that ? I am a little new to git so please bare with me.
-
VonC over 9 yearsSee if the repo you just cloned has a
.gitmodules
file in it. Then open that file, and try cloning the url(s) listed in it. -
Ke Li over 4 yearsAs @VonC mentioned, after checking the contents within
.gitmodules
, I see there's a different repo than the main one in which I have to refresh my ssh key. After doing so, it's working.
-
-
famfamfam about 5 yearsIt must be accepted answer by smart way, just go to submodule folder then clone https link -> WORK 100%
-
Arcyno over 3 yearsthe issue is when it occurs in a windows gitlab runner... it uses CMD by default !
-
Alexis Wilke over 3 years@famfamfam Absolutely not. If you need to do edits and be able to push your changes, you don't want to use the HTTPS protocol.
-
Adam Johns over 2 yearsI had never configured an ssh key, but everything worked fine after I configured my ssh key
-
tapizquent over 2 yearsWas getting the same issue with Windows Terminal. Using Git Lab and running
git submodule update
fixed it -
Özgür Ağcakaya almost 2 years+ This might be a problem with the password protected keys. I've prompted to re-enter the password only from gitbash.