1

When trying to build in Go, I get the following Git error:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic). 
fatal: Could not read from remote repository.

What is the cause for this?

I am able to clone the same repository successfully using both HTTP and SSH and have the appropriate permissions assigned to it as confirmed by the GitLab UI.

I'm running MacOS Monterey.
Any help would be greatly appreciated.

2
  • That's an ssh error, not a Git error: Git runs ssh, ssh fails, and then Git stops because it needed ssh to succeed. You can sometimes work around it by having Git use https instead of ssh (see VonC's answer), but if ssh should work, poke around with it (ssh, that is) to see why it isn't working. Commented Oct 13, 2022 at 17:04
  • You're right. It was an SSH issue. When I switched from SSH to HTTPS, everything worked. Thanks for your feedback. Commented Oct 14, 2022 at 13:21

1 Answer 1

4

Check your go.mod in the Go project you are compiling.

It might refer to modules who might be private, and that you might not have the right to clone.
Or you can force using HTTPS instead of SSH for any dependencies, as I did here.

The OP Foobar confirms in the comments:

git config --global url."gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.acme.com/".insteadOf [email protected]:
Sign up to request clarification or add additional context in comments.

3 Comments

@Foobar Great, well done! What did you do to make it work?
I used the following as mentioned by you above: git config --global url."gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.acme.com/".insteadOf [email protected]:
@Foobar Thank you for your feedback. I have included your comment in the answer for more visibility.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.