7

Why are people having this problem?

$ git clone --recursive git@github.com:acani/Chats.git Cloning into 'Chats'... Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

https://github.com/acani/Chats/issues/53#issuecomment-118014684

I've read some answers that say to change the submodule URL from SSH to HTTP, but why should I have to do that. I don't want to do that. I want to keep it SSH so that I don't have to enter my username & password into Terminal if I want to push. Everyone can clone the SSH URL fine, so why can't they recursively clone it as a submodule?

ma11hew28
  • 121,420
  • 116
  • 450
  • 651
  • Possible duplicate: http://stackoverflow.com/questions/25957125/git-submodule-permission-denied – Melebius Jul 02 '15 at 12:41
  • @ma1 Did I answered your question with the workaround I proposed below? – VonC Dec 18 '18 at 22:17
  • @VonC Sorry, I didn't try your workaround. I just switched from the SSH protocol to the Git protocol. Thank you for answering anyway though. – ma11hew28 Dec 19 '18 at 16:43

3 Answers3

8

As a workaround, you can try using https url for any github repo:

cd myParentRepo
git config url.https://github.com/.insteadOf ssh://git@github.com/
# or
git config url.https://github.com/.insteadOf git@github.com:
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
4

The SSH protocol doesn’t support anonymous access to a Git repository.

So, don't use the SSH protocol. Instead, use either the Smart HTTP protocol (recommended) or the Git protocol.

For every submodule URL in your repository's .gitmodules file, replace git@github.com: with either https://github.com/ (to use the Smart HTTP protocol) or git://github.com/ (to use the Git protocol).

More info: Git - The Protocols

ma11hew28
  • 121,420
  • 116
  • 450
  • 651
0

This works for me in the .gitmodules file:

url = git+ssh://git@github.com/path-to-repo