Unable to "go get" module from private github repo on centos 7

1.5k Views Asked by At

I am unable to "go get" module from private github repo

I getting following error message

go get 
go: github.com/xxxxx/[email protected]: invalid version: git ls-remote -q origin in /usr/local/bin/pkg/mod/cache/vcs/e3eb4c4c224c608f41c609b576ad32d5a979877e8a7f951b716f1242957c7ddd: exit status 128:
        remote: Support for password authentication was removed on August 13, 2021.
        remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
        fatal: Authentication failed for 'https://github.com/xxxxx/xxxxx-service/

I tried with the following method. Added the the github credentials in ~/.netrc:

machine github.com 
login <username> 
password <Personal Access Token>`

Added the following entries in ~/.gitconfig file

[url "[email protected]:"]
        insteadOf = https://github.com/
[url "ssh://[email protected]/"]
        insteadOf = https://github.com/

Added the environment variable

export GOPRIVATE=github.com/<username>/*
export GO111MODULE=on

Still getting the same Authentication error.

1

There are 1 best solutions below

1
Otávio Monteagudo On

Github has disabled simple password authentication from command line interfaces since 2021. Take a look at the third line of the first terminal output block you've sent in your question.

You should create an ssh key and add it to your machine's ssh-agent or install the github-cli package and login through it.

Here are instructions to go get using SSH: https://gist.github.com/StevenACoffman/866b06ed943394fbacb60a45db5982f2