I am able to clone a repository with ssh just fine.
git clone git@bitbucket.org:team-name/utils.git
However, when this same repo is included as a submodule in another project, I get a Permission Denied (public key) error.
Here is the exact output I get
$ git submodule update
Cloning into '/Users/me/code/my-project/utils'...
me@bitbucket.org: 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 'ssh://bitbucket.org/team-name/utils.git' into submodule path '/Users/me/code/my-project/utils' failed
Failed to clone 'utils'.
I want to re-iterate that I definitely have access to the repository and am able to clone the repository via ssh without any problems. This ONLY happens when the repository is included as a submodule in another project.
This is the content of my .gitmodules file
[submodule "utils"]
path = utils
url = ssh://bitbucket.org/team-name/utils.git
I've tried everything I can think of.
- Deleted all ssh keys
- Regenerated keys (and added to Bitbucket account)
- I've run ssh -T git@bitbucket.org (it works)
I am on macOS Monterey (12.1).
git version 2.32.0 (Apple Git-132)
I followed the
ssh setup instructions multiple times.