Clone --recurse-submodules permission denied

Hope this is the right section.
Note: I have had to corrupt certain information because as a new user I can only have two links in the message.
I have been given access to a private repository which currently contains one submodule. When I try to clone the repository including the submodules I get errors.
I have tried using Ubuntu 18 and 20 platforms.
$ git clone --recurse-submodules https ://github.com/…/php-api.git
results in
Cloning into ‘php-api’…
Username…
Password… (I put my key in here)
remote: Enumerating objects: 144, done.
remote: Counting objects: 100% (144/144), done.
remote: Compressing objects: 100% (72/72), done.
remote: Total 144 (delta 56), reused 143 (delta 55), pack-reused 0
Receiving objects: 100% (144/144), 46.66 KiB | 2.03 MiB/s, done.
Resolving deltas: 100% (56/56), done.
Submodule ‘app/public/home’ (git@githubdotcom:…/home.git) registered for path ‘app/public/home’
Cloning into ‘/home/dave/Projects/test/php-api/app/public/home’…
The authenticity of host ‘githubdotcom (140.82.121.3)’ can’t be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type ‘yes’, ‘no’ or the fingerprint: yes
Warning: Permanently added ‘githubdotcom,140.82.121.3’ (RSA) to the list of known hosts.
git@githubdotcom: Permission denied (publickey).
fatal: Could not read from remote repository.

  1. I don’t see why the main part of the clone works without problems but when it gets to cloning the submodule suddenly githubdotcom is unknown, but it is the right domain and the RSA key seems to be correct so I accept.
  2. I am apparently unable to read the submodule. I tried just cloning the submodule, but that says the repository can not be found.
    I can visit the repository at githubdotcom and examine the contents just fine.
    My Git client version on Ubuntu 20.04 is currently 2.25.1.
    Any clues as to what is the problem here?

:wave: Welcome!

First - feel free to use codeblocks - that should allow a lot more freedom with sharing output. Just enclose the output in backticks or use the </> option in the formatting bar. Links formatted that way shouldn’t cause any hassle.

It looks as though the remote url for the submodule is using SSH and not HTTPS, which you are using to clone the main repository. This means that you’d need an SSH key for this to complete. It’s not finding a valid key, so this fails.

The path of least resistance here is probably creating an SSH key and cloning with SSH.

The submodule url can be changed as well, but obviously that’s easier done after you’ve cloned the project.

1 Like

Thanks for the reply.
We don’t have a public key set up, so that sounds like the answer.
Don’t know how this repository was created requiring SSH, when all the ones we have created previously are perfectly happy using HTTPS.
I just tried creating a new repository and I don’t see any options for SSH v HTTPS.
Any clues what I should be looking for there?

The repository itself is fine either way - you can clone using HTTPS or SSH, that doesn’t matter.

But the way this particular submodule was set up, .gitmodules has saved the SSH URL and not the HTTPS.

You can read more about .gitmodules here:

https://git-scm.com/docs/gitmodules/2.25.0

Thanks for that link.
The instructions starting at Checking for existing SSH keys - GitHub Docs were very helpful for setting up an SSH key. I only looked at the Linux information, but was impressed with the clarity of the instructions.
Problem solved :grin:

1 Like