We use github enterprise server over a VPN.
If I type:
go get privateserver.com/path/to/myproject.git
I get this result:
package privateserver.com/path/to/myproject.git: cannot download, privateserver.com/path/to/myproject uses insecure protocol
Or removing the .git suffix I get:
package privateserver.com/path/to/myproject: unrecognized import path "privateserver.com/path/to/myproject" (parse https://privateserver.com/path/to/myproject?go-get=1: no go-import meta tags ())
It seems there are many similar questions on google searches but have found no answers that actually work.
What I really want to end up with is automation of docker builds.
Inside my docker file I require a go get. But I can't store the credentials inside the docker file.
Note: --insecure doesn't work. See bottom of question.
Just tried go get with -insecure -v options.
I get the following output:
matthewh#xen:~/go/src/$ go get -insecure -v privateserver.com/path/to/myproject.git
# cd .; git ls-remote git://privateserver.com/path/to/myproject
fatal: remote error:
GitHub private mode is enabled. Git protocol is disabled. Use authenticated http or ssh access instead.
# cd .; git ls-remote https://privateserver.com/path/to/myproject
fatal: could not read Username for 'https://privateserver.com': terminal prompts disabled
# cd .; git ls-remote http://privateserver.com/path/to/myproject
fatal: could not read Username for 'https://privateserver.com': terminal prompts disabled
# cd .; git ls-remote git+ssh://privateserver.com/path/to/myproject
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://privateserver.com/path/to/myproject
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
privateserver.com/path/to/myproject.git (download)
# cd .; git clone privateserver.com/path/to/myproject /home/matthewh/go/src/privateserver.com/path/to/myproject.git
fatal: repository 'privateserver.com/path/to/myproject' does not exist
package privateserver.com/path/to/myproject.git: exit status 128
The get command supports using http by using the -insecure flag as shown below:
go get -insecure privateserver.com/path/to/myproject.git
The default is secure HTTPS in order to prevent man in the middle attacks as described in Git Issue.
Related
I'm on a Apple MAC Laptop, go get command is not working.
I have normal git access, I can git clone and git commit and git push. Why does this go get command not work?
temp % go get github.com/MYCOMPANY/myproject
go get: module github.com/MYCOMPANY/myproject: git ls-remote -q origin in /Users/someuser/go/pkg/mod/cache/vcs/1872293eea4df8de643499713e2d8621a72624bb2514a7a88c1182d1869ef891: exit status 128:
ssh: Could not resolve hostname github.com:MYCOMPANY: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
temp % go get github.com/MYCOMPANY/myproject
go get: module github.com/MYCOMPANY/myproject: git ls-remote -q origin in /Users/someuser/go/pkg/mod/cache/vcs/1872293eea4df8de643499713e2d8621a72624bb2514a7a88c1182d1869ef891: exit status 128:
ssh: Could not resolve hostname github.com:MYCOMPANY: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
This is what works for me, based on #elulcao
go env -w GOPRIVATE=github.com/COMPANYNAME
git config --global --add url."git#github.com:".insteadOf "https://github.com/"
Then I can do
go mod download
In the projects git folder or go get
'go get' by default does not support private repositories. It only supports public repos.
If you want to get private repos please refer to this link
This question already has answers here:
What's the proper way to "go get" a private repository?
(17 answers)
Closed 2 years ago.
I want to use go get to get a package located in a private GitLab repository. My go version is go1.15.4 darwin/amd64. And the current directory has a go.mod file.
When I run go get -v git.xxx.com/path-to/package#v0.0.3, It shows
get "git.xxx.com/path-to/package": found meta tag get.metaImport{Prefix:"git.xxx.com/path-to/package", VCS:"git", RepoRoot:"https://git.xxx.com/path-to/package.git"} at //git.xxx.com/path-to/package?go-get=1
get "git.xxx.com/path-to": found meta tag get.metaImport{Prefix:"git.xxx.com/path-to", VCS:"git", RepoRoot:"https://git.xxx.com/path-to.git"} at //git.xxx.com/path-to?go-get=1
Enter passphrase for key '~/.ssh/id_rsa':
And after I input my password it hangs for hours without showing anything.
I also tried-
$ sudo go get git.xxx.com/path-to/package#v0.0.3
go get git.xxx.com/path-to/package#v0.0.3: git.xxx.com/path-to/package#v0.0.3: invalid version: unknown revision v0.0.3
But the repository indeed has a tag v0.0.3. And If I try without version-
$ sudo go get git.xxx.com/path-to/package
go get git.xxx.com/path-to/package: module git.xxx.com/path-to/package: git ls-remote -q origin in ~/go/pkg/mod/cache/vcs/bcb4baa8ab83c8bb452456922f12d22e1981b76bd2649d163d0c53c6: exit status 128:
gitlab#git.xxx.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
But I can clone this repository. So I have access rights and have this in ~/.gitconfig file
[url "ssh://gitlab#git.xxx.com:2222/"]
insteadOf = https://git.xxx.com/
Note that, everything was okay in my system (I could use go get) until I ran this command go clean -cache -modcache -i -r following this blog.
I am wondering why the port in the git config?, maybe is not the root cause but you can try
[url "git#gitlab.com:"]
insteadOf = https://gitlab.com/
Let's assume that you already set .git config sshd_config correctly.
You can try
cd $HOME # out of gopath
env GO111MODULE=off go get git.xxx.com/path-to/package
you can try use GOPRIVATe evn variable
https://golang.org/cmd/go/#hdr-Module_configuration_for_non_public_modules
Hello i have a gitlab server and the web interface works just as ssh -T git#mijnstageportaal.nl,
but when i try to upload a folder to a blaco project its says this
git init
git remote add origin http://mijnstageportaal.nl/marijnboeve/sinterklaas-intocht
git add .
git commit -m "Initial commit"
git push -u origin master
Reinitialized existing Git repository in
/Users/marijnboeve/websites/sinterklaasintocht/.git/
fatal: remote origin already exists.
HEAD detached from v8.0.1
nothing to commit, working tree clean
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Look at
Please make sure you have the correct access rights
and the repository exists.
Most probably, you don't have a public key id_rsa at path /Users/YOUR_USER_NAME/.ssh.
You should generate it, e.g. ssh-keygen -t rsa -b 2048 -C "email#example.com" (see https://docs.gitlab.com/ee/ssh/).
Or, repository at http://mijnstageportaal.nl/marijnboeve/sinterklaas-intocht really doesn't exist. You can check it with your Web client, if possible, or ask a repository owner.
Trying to get Jenkins to run with Gradle etc. Please note that this is a Windows 10 OS. Not Linux.
I want to use a git repo on my local machine, under D:\temp\.git\. There is a file HEAD there.
On the "Source Code Management" page I enter the following in Repository URL:
file:///D:/temp/.git/
(NB I have played around a lot with the number (and type) of slashes here... nothing works)
The response comes:
Failed to connect to repository : Command "git.exe -c
core.askpass=true ls-remote -h file:///D:/temp/.git/ HEAD" returned
status code 128: stdout: stderr: fatal: '/D:/temp/.git/' does not
appear to be a git repository fatal: Could not read from remote
repository. Please make sure you have the correct access rights and
the repository exists.
I note that it says "from remote repository". Just wondering if it might be a question of tweaking something somewhere to specify a local repository... ?
Plus I also then tried running this same command at a DOS prompt without and then with Administrator rights:
D:\temp>git.exe -c core.askpass=true ls-remote -h file:///D:/temp/.git/HEAD fatal: Invalid gitfile format:
D:/temp/.git/HEAD fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
... which is puzzling. "invalid gitfile format" - what's that about? Plus the "access rights" thing: could it be that this is happening due to some nonsense to do with Windows UAC? But even with Admin rights I get the same message.
A bit later:
This command works at the command prompt, including as a non-administrator, if you omit the word "HEAD":
D:>git.exe -c core.askpass=true ls-remote -h file:///D:/temp
a4ca18f7b218ef57b07f8dceef89ab6bdb5839a6 refs/heads/master
D:>git.exe -c core.askpass=true ls-remote -h file:///D:/temp/.git
a4ca18f7b218ef57b07f8dceef89ab6bdb5839a6 refs/heads/master
In your case, you don't want to configure a Git repository to track. Because you are working locally (only), it would be sufficient to configure Custom Workspace to point to your repository (General -> Advanced).
This would be D:\temp, not D:\temp\.git, because the .git directory is merely where Git keeps its information about your repository.
I am trying to clone private repository using Python. I am using Git Python package to clone the repository but I am getting an error:
Error :
GitCommandError: 'git clone -v https://github.mit.edu/mitx/content-mit-1690rgit edxcourse' returned exit status 128: Cloning into 'edxcourse'...
remote Repository not found.
fatal : Authentication failed for 'https://github.mit.edu/mitx/content-mit-1690.r.git/'
However I am a member of this repository and I have access to the repository.
In your case, gitpython merely returns an error it received from the git executable it envoked.
If you call git clone -v https://github.mit.edu/mitx/content-mit-1690rgit on the commandline, you will receive a similar error, indicating something might be wrong with your URL. Possibly it is the rgit extension, which might be a typo.
Maybe one of the devs can confirm this as I have only been playing around with Git-Python for the last few hours.
When cloning over http(s) it seems to rely on the .netrc file rather than asking for auth like the Git CLI client would.
cat > ${HOME}/.netrc < EOF
machine github.mit.edu
login <username>
password <password>
EOF
chmod 600 ${HOME}/.netrc
If you're on Windows, that works via Cygwin too.
The repository which I was trying to Clone is a secured repo. So I need to establish a secure ssh authentication connection. and then it worked for me.