nvm: Unable to clone repo with a deploy key
We’re unable to clone this repo when using the deploy key that’s set up in our CircleCI. The key is correctly set up in github as a deploy key and we’ve been using it since 2021 with no issues (yes, we should probably rotate it). Here’s the error message that git returns when trying to clone from within the CircleCI container:
root@408047b2bc79:~# git clone git@github.com:nvm-sh/nvm.git
Cloning into 'nvm'...
ERROR: Permission to nvm-sh/nvm.git denied to deploy key
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Using that same key to clone another public repo (ex: node) works fine so I’m assuming the issue is with this repo’s settings rather than a global change.
Can you please look into any recent changes to this repo’s settings?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 37
- Comments: 19 (1 by maintainers)
Confirmed, the issue seems resolved. I checked the
.gitconfigfiles between the failed and successful builds (had SSH sessions open to both containers) and there are no differences. So far it’s looking like this was a github issue rather than CircleCI or the settings of a specific repo but that’s just guessing from limited info.I’ll keep the issue open for another hour or so just while we confirm the fix is stable and close it out after. Thanks for the group debugging and workarounds everyone!
I’ve opened a support ticket with CircleCI and I suggest everyone that can do the same so they get eyes on this.
An ugly (TEMPORARY!) workaround for people that need this working now: use a
userkey in CircleCI instead of deploy.We saw only our repos using deploy keys failing like this, and the few that make use of user keys for various reasons were not failing.
Be sure to make note of any projects you switch to user keys so you can go back and revert them to deploy keys!
RESOLVED! It is working Again!!!
Seems to be working now
Running this command in a step before installing Node fixes the issue:
Not completely sure about the repercussions though—nor why this config would be needed in the first place.
I too am here because my CircleCI builds are failing, but I can reproduce the issue locally by generating a new SSH key, adding it as a deploy key to a repo, and adding it to my SSH agent with no other keys, so it doesn’t seem to be an issue with CircleCI specifically. I was also able to clone other public repos with the same key and configuration.
Edit: I do think it’s CircleCI specifically - they must have forced cloning over ssh rather than https with some git config.
cross-posting here just to amplify:
I think this is just an issue across the board with public github repos, we are also seeing:
my guess is that either circleci made a change to inject the insteadOf directive into the gitconfig:
or github changed the ability for deploy keys to clone public repos.
This seems to happen because CircleCI sets git to change all GitHub HTTPS URLs to SSH URLs.
Is it possible that a deploy key was recently added to this repo?