I created the private repository using the coding.net.
I use docker images alpine and centos.
I can go get git.coding.net/alphayan/orionv2.git successful
from docker-centos, but I can't go get git.coding.net/alphayan/test.git
from docker-alpine.It returns an error stating:
/go/src # go get -u -v git.coding.net/alphayan/test.git
# cd .; git ls-remote https://git.coding.net/alphayan/test
fatal: could not read Username for 'https://git.coding.net': terminal prompts disabled
# cd .; git ls-remote git+ssh://git.coding.net/alphayan/test
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
# cd .; git ls-remote ssh://git.coding.net/alphayan/test
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
package git.coding.net/alphayan/test.git: cannot download, git.coding.net/alphayan/test uses insecure protocol
From centos it let me use the username and password:
[root@83fc8067fc95 /]# go get -u -v git.coding.net/alphayan/test.git
Username for 'https://git.coding.net':
finally, I find it caused by the git's version, the centos with git 1.8.3 and the alpine with git 2.11.0.
then I change the centos git's version with 2.11.0, becomes the same wrong with alpine.
I think I can modify golang or git source file solve this problem,
could someone help me? thinks~!
This error happens because by default go get
doesn't use terminal input. This behaviour can be changed by modifying environment variable GIT_TERMINAL_PROMPT
, which was introduced in git 2.3. That's why the go get
command behaves differently in CentOS 7 (git 1.8) and Alpine 3.5 (git 2.11).
You can work your way around the issue in git >= 2.3
by running go get
as follows:
$ GIT_TERMINAL_PROMPT=1 go get github.com/foo/bar
Username for 'https://github.com':
If you have multiple go get
calls then you can export that environment variable before running the commands:
$ export GIT_TERMINAL_PROMPT=1
$ go get github.com/foo/bar
Username for 'https://github.com':
$ go get github.com/foo/baz
Username for 'https://github.com':
You could try through ssh, if your public ssh key is registered on coding.net.
See "go get for private repos in docker" as an example:
FROM golang:1.6
RUN echo "[url \"[email protected]:\"]\n\tinsteadOf = https://github.com/" >> /root/.gitconfig
RUN mkdir /root/.ssh && echo "StrictHostKeyChecking no " > /root/.ssh/config
ADD . /go/src/github.com/company/foo
CMD cd /go/src/github.com/company/foo && go get github.com/company/bar && go build -o /foo
with the build step:
docker build -t foo-build .
docker run --name=foo-build -v ~/.ssh/id_rsa:/root/.ssh/id_rsa foo-build
docker cp foo-build:/foo foo
docker rm -f foo-build
docker rmi -f foo-build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With