Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go get 403 Forbidden Access denied private bitbucket repositories #46344

Closed
SHUFIL opened this issue May 24, 2021 · 5 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@SHUFIL
Copy link

SHUFIL commented May 24, 2021

What version of Go are you using (go version)?

$ go version
go version go1.14.9 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ubuntu/.cache/go-build"
GOENV="/home/ubuntu/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY="bitbucket.org/project-name/second-repo"
GONOSUMDB="bitbucket.org/project-name/second-repo"
GOOS="linux"
GOPATH="/home/ubuntu/go"
GOPRIVATE="bitbucket.org/project-name/second-repo"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/ubuntu/repo-name/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build436192813=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I have added private key in bitbucket , and can clone using git@bitbucket.org:project-name/repo-name.git
added git config --global url."git@bitbucket.org:project-name".insteadOf "https://bitbucket.org/project-name"

also Added GOPRIVATE=bitbucket.org/project-name/second-repo

What did you expect to see?

I need to pull library from second repositary

What did you see instead?

go get bitbucket.org/project-name/second-repo: reading https://api.bitbucket.org/2.0/repositories/project-name/second-repo?fields=scm: 403 Forbidden
server response: Access denied. You must have write or admin access.

@mknyszek
Copy link
Contributor

mknyszek commented May 24, 2021

I'm not positive, but I think GOPRIVATE only works with Go modules. Is your repository a module?

EDIT: Actually, I'm not sure how (or if) we support cloning private repositories via an SSH key at all.

CC @bcmills @jayconrod @matloob via https://dev.golang.org/owners

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 24, 2021
@mknyszek mknyszek added this to the Backlog milestone May 24, 2021
@bcmills
Copy link
Contributor

bcmills commented May 24, 2021

The go command uses HTTPS to identify the repository corresponding to an import path, unless some prefix of the path has an explicit .git or similar suffix (see https://golang.org/ref/mod#vcs-find).

As a consequence, merely adding a private SSH key does not suffice — either you need to add HTTPS credentials (such as in a .netrc file; see https://golang.org/ref/mod#private-module-repo-auth), or you need to add an explicit .git suffix to the appropriate element of the import path.

@bcmills bcmills added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 24, 2021
@muhaarif
Copy link

Export the GOPRIVARE equal to bitbucket path.

Check with this solution,
https://community.atlassian.com/t5/Bitbucket-questions/How-do-I-run-go-get-on-a-private-repo/qaq-p/1385040

@SHUFIL
Copy link
Author

SHUFIL commented May 26, 2021

Resolved the issue using blow steps , this is i used git clone using https.

1,
cat ~/.gitconfig
[user]
        email = username@domain.com
        name = username
2, `export GOPRIVATE=bitbucket.org/project-name/second-repo`
3,` GIT_TERMINAL_PROMPT=1 go get -v bitbucket.org/project-name/second-repo   `

It will ask user name and password for 3 times , thats it.

If you using ssh key , it will not ask user name and password , at last stage , and  we need to add below command at first 


`git config --global url."git@bitbucket.org:project-name".insteadof "https://bitbucket.org/project-name"`
  

@bcmills
Copy link
Contributor

bcmills commented May 26, 2021

Sounds like there isn't anything more to do here, beyond the documentation already requested in #29953.

@bcmills bcmills closed this as completed May 26, 2021
@golang golang locked and limited conversation to collaborators May 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants