Foobar
Foobar

Reputation: 931

Git Error with Go Build and Other Go Commands

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.

Upvotes: 1

Views: 649

Answers (1)

VonC
VonC

Reputation: 1323983

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]:

Upvotes: 4

Related Questions