I'm trying to do a simple git clone https://github.com/org/project.git on a CentOS box but get:
error: The requested URL returned error: 401 while accessing
https://github.com/org/project.git/info/refs
fatal: HTTP request failed
It never prompts me for my username/password, just fails.
I can make the exact same call on my Mac no problem- what am I missing?
The answer was simple but not obvious:
Instead of:
git clone https://github.com/org/project.git
do:
git clone https://username#github.com/org/project.git
or (insecure)
git clone https://username:password#github.com/org/project.git
(Note that in the later case, your password will may be visible by other users on your machine by running ps u -u $you and will appear cleartext in your shell's history by default)
All 3 ways work on my Mac, but only the last 2 worked on the remote Linux box. (Thinking back on this, it's probably because I had a global git username set up on my Mac, whereas on the remote box I did not? That might have been the case, but the lack of prompt for a username tripped me up... )
Haven't seen this documented anywhere, so here it is.
You can manual disable ssl verfiy, and try again. :)
git config --global http.sslverify false
I met the same problem, the error message and OS info are as follows
OS info:
CentOS release 6.5 (Final)
Linux 192-168-30-213 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
error info:
Initialized empty Git repository in /home/techops/pyenv/.git/
Password:
error: while accessing https://waterdrops#github.com/pyenv/pyenv.git/info/refs
fatal: HTTP request failed
git & curl version info
git info :git version 1.7.1
curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz
debugging
$ curl --verbose https://github.com
About to connect() to github.com port 443 (#0)
Trying 13.229.188.59... connected
Connected to github.com (13.229.188.59) port 443 (#0)
Initializing NSS with certpath: sql:/etc/pki/nssdb
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
NSS error -12190
Error in TLS handshake, trying SSLv3...
GET / HTTP/1.1
User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Host: github.com
Accept: /
Connection died, retrying a fresh connect
Closing connection #0
Issue another request to this URL: 'https://github.com'
About to connect() to github.com port 443 (#0)
Trying 13.229.188.59... connected
Connected to github.com (13.229.188.59) port 443 (#0)
TLS disabled due to previous handshake failure
CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
NSS error -12286
Closing connection #0
SSL connect error
curl: (35) SSL connect error
after upgrading curl , libcurl and nss , git clone works fine again, so here it is. the update command is as follows
sudo yum update -y nss curl libcurl
Make sure you have git 1.7.10 or later, it now prompts for user/password correctly. (You can download the latest version here)
I had to specify user name to work on 1.7.1 git version:
git remote set-url origin https://username#github.com/org/project.git
As JERC said, make sure you have an updated version of git. If you are only using the default settings, when you try to install git you will get version 1.7.1. Other than manually downloading and installing the latest version of get, you can also accomplish this by adding a new repository to yum.
From tecadmin.net:
Download and install the rpmforge repository:
# use this for 64-bit
rpm -i 'http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm'
# use this for 32-bit
rpm -i 'http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm'
# then run this in either case
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
Then you need to enable the rpmforge-extras. Edit /etc/yum.repos.d/rpmforge.repo and change enabled = 0 to enabled = 1 under [rpmforge-extras]. The file looks like this:
### Name: RPMforge RPM Repository for RHEL 6 - dag
### URL: http://rpmforge.net/
[rpmforge]
name = RHEL $releasever - RPMforge.net - dag
baseurl = http://apt.sw.be/redhat/el6/en/$basearch/rpmforge
mirrorlist = http://mirrorlist.repoforge.org/el6/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
[rpmforge-extras]
name = RHEL $releasever - RPMforge.net - extras
baseurl = http://apt.sw.be/redhat/el6/en/$basearch/extras
mirrorlist = http://mirrorlist.repoforge.org/el6/mirrors-rpmforge-extras
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-extras
enabled = 0 ####### CHANGE THIS LINE TO "enabled = 1" #############
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
[rpmforge-testing]
name = RHEL $releasever - RPMforge.net - testing
baseurl = http://apt.sw.be/redhat/el6/en/$basearch/testing
mirrorlist = http://mirrorlist.repoforge.org/el6/mirrors-rpmforge-testing
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-testing
enabled = 0
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
Once you've done this, then you can update git with
yum update git
I'm not sure why, but they then suggest disabling rpmforge-extras (change back to enabled = 0) and then running yum clean all.
Most likely you'll need to use sudo for these commands.
I was able to get a git 1.7.1 to work after quite some time.
First, I had to do disable SSL just so I could pull:
git config --global http.sslverify false
Then I could clone
git clone https://github.com/USERNAME/PROJECTNAME.git
Then after adding and committing i was UNABLE to push back.
So i did
git remote -v
origin https://github.com/USERNAME/PROJECTNAME.git (fetch)
origin https://github.com/USERNAME/PROJECTNAME.git (push)
to see the pull and push adresses:
These must be modified with USERNAME#
git remote set-url origin https://USERNAME#github.com/USERNAME/PROJECTNAME.git
It will still prompt you for a password, which you could add with
USERNAME:PASSWORD#github.....
But dont do that, as you save your password in cleartext for easy theft.
I had to do this combination since I could not get SSH to work due to firewall limitations.
This is the dumbest answer to this question, but check the status of GitHub. This one got me :)
I had the same problem and error. In my case it was the https_proxy not set.
Setting the https_proxy environment variable fixed the issue.
$ export https_proxy=https://<porxy_addres>:<proxy_port>
Example:
$ export https_proxy=https://my.proxy.company.com:8000
Hope this help somebody.
Related
Everything was working fine but suddenly I am getting the error:
fatal: unable to access
'https://username#bitbucket.org/name/repo_name.git/':
gnutls_handshake() failed: Handshake failed
I am getting this on my computer as well as an EC2 instance. When I tried on another computer then it is working fine there.
I have tried many solutions from Stackoverflow and from other forums. but nothing worked!
On the computer, os is Linux mint 17 and on EC2 instance, Ubuntu 14.04.6 LTS.
What can be the issue and what should I do to fix this issue?
Ran into the same issue on a server with Ubuntu 14.04, and found that on Aug 24, 2020 bitbucket.org changed to no longer allow old ciphers, see https://bitbucket.org/blog/update-to-supported-cipher-suites-in-bitbucket-cloud
This affects https:// connections to bitbucket, but does not affect ssh connections, so the quickest solution for me was to add an ssh key to bitbucket, and then change the remote from https to ssh.
The steps to change the remote I found from here, and they are essentially:
# Find the current remote
git remote -v
origin https://user#bitbucket.org/reponame.git (fetch)
origin https://user#bitbucket.org/reponame.git (push)
# Change the remote to ssh
git remote set-url origin git#bitbucket.org:reponame.git
# Check the remote again to make sure it changed
git remote -v
There is more discussion about the issue on the Atlassian forums at https://community.atlassian.com/t5/Bitbucket-questions/fatal-unable-to-access-https-bitbucket-org-gnutls-handshake/qaq-p/1468075
The quickest solution is to use SSH instead of HTTPS. I tried other ways to fix the issue but it was not working.
The following are steps to replace HTTPS from SSH:
Generate ssh key using ssh-keygen on the server.
Copy the public key from the generated id_rsa.pub file from step 1 and add it at following links depending on the repository host -
Bitbucket - https://bitbucket.org/account/settings/ssh-keys/
Github - https://github.com/settings/ssh/new
Gitlab - https://gitlab.com/profile/keys
Now run the following command to test authentication from the server command line terminal
Bitbucket
ssh -T git#bitbucket.org
Github
ssh -T git#github.com
Gitlab
ssh -T git#gitlab.com
Go to the repo directory and open .git/config file using emac or vi or nano
Replace remote "origin" URL (which starts with https) with the following -
For Bitbucket - git#bitbucket.org:<username>/<repo>.git
For Github - git#github.com:<username>/<repo>.git
For Gitlab - git#gitlab.com:<username>/<repo>.git
sudo bash
mkdir upgrade
cd upgrade
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
tar xpvfz openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./Configure
make ; make install
cd ..
wget https://curl.haxx.se/download/curl-7.72.0.tar.gz
tar xpvfz curl-7.72.0.tar.gz
cd curl.7.72.0
./configure --with-ssl=/usr/local/ssl
make ; make install
cd ..
git clone https://github.com/git/git
cd git
vi Makefile, change prefix= line to /usr instead of home
make ; make install
Gitlab server was installed on CentOs 6.7 by Nginx using in local network. I can log in server, add users, projects etc via browser. But users can't push/pull own projects via Windows GIT Bash:
$ git push -u origin master
GitLab: Failed to authorize your Git request: internal API unreachable ...
To clarify situation on server side I've run:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production which show the error:
...
Running /home/git/gitlab-shell/bin/check
Check GitLab API access: FAILED: Failed to connect to internal API
gitlab-shell self-check failed
Try fixing it:
Make sure GitLab is running;
Check the gitlab-shell configuration file:
sudo -u git -H editor /home/git/gitlab-shell/config.yml
Please fix the error above and rerun the checks.
...
My /home/git/gitlab-shell/config.yml:
user: git
gitlab_url: "https://git/"
http_settings:
self_signed_cert: false
ca_file: "/etc/nginx/ssl/gitlab.crt"
ca_path: "/etc/nginx/ssl"
repos_path: "/home/git/repositories/"
auth_file: "/home/git/.ssh/authorized_keys"
redis:
bin: "/usr/bin/redis-cli"
namespace: resque:gitlab
socket: "/var/run/redis/redis.sock"
log_level: INFO
audit_usernames: false
The error msg in gitlab-shell.log is:
WARN -- : Failed to connect to internal API <GET https://git//api/v3/internal/check>:
#<SocketError: getaddrinfo: Name or service not known>
git alias was written in /etc/hosts and work fine (pinging successfully). cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
192.168.1.21 git
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
If i change git to localhost in gitlab-shell/config.yml I'll get in log:
WARN -- : Failed to connect to internal API <GET https://localhost//api/v3/internal/check>:
#<OpenSSL::SSL::SSLError: hostname "localhost" does not match the server certificate>
If I change git to IP notation 192.168.1.21 I'll get:
WARN -- : Failed to connect to internal API <POST https://192.168.1.21//api/v3/internal/allowed>:
#<SocketError: getaddrinfo: Name or service not known>
SSL is normal. User certificate was set up. On client side ssh -T git#git output
Welcome to GitLab,...
Users can sign in https://git server by browser etc.
Additional info: sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
System information
System: CentOS 6.7
Current User: git
Using RVM: no
Ruby Version: 2.2.3p173
Gem Version: 2.4.8
Bundler Version:1.10.6
Rake Version: 10.4.2
Sidekiq Version:3.3.0
GitLab information
Version: 7.14.1
Revision: 348b983
Directory: /home/git/gitlab
DB Adapter: mysql2
URL: https://git
HTTP Clone URL: https://git/some-group/some-project.git
SSH Clone URL: git#git:some-group/some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 2.6.4
Repositories: /home/git/repositories/
Hooks: /home/git/gitlab-shell/hooks/
Git: /usr/bin/git
Can you give me ideas to fix problem (many answers for this question offer adding localhost 127.0.0.1 to /etc/host , but my version of this file is contain it )?
P.S.
Changing gitlab_url: "https://git/" to gitlab_url: "https://git" or "https://git:8080/" don't solve problem. We have follow msg in log:
WARN -- : Failed to connect to internal API <GET https://git/api/v3/internal/check>:
#<SocketError: getaddrinfo: Name or service not known etc
P.S.S. Problem was solved by editing /gitlab-shell/config.yml
gitlab_url: "https://localhost/"
http_settings:
self_signed_cert: true
Only the showed combination of self_signed_cert & gitlab_url can help solving the problem in my case.
Problem was solved by editing /gitlab-shell/config.yml
gitlab_url: "https://localhost/"
http_settings:
self_signed_cert: true
Only the showed combination of self_signed_cert & gitlab_url can help solving the problem in my case.
Our setup:
Gitlab CE
Gitlab 7.8.4
Git-shell: 2.5.4
Gitlab API: v3
Ruby: 2.1.5p273
Rails: 4.1.1
This is test is on a private repository owned by the same user that is trying to push to it (user is admin). Environment check is clean with no errors. Same error whether we try HTTPS or SSH. SSH worked before the upgrade.
Error:
git push -u origin master
/usr/local/lib/ruby/2.1.0/json/common.rb:155:in `parse': 757: unexpected token at 'false' (JSON::ParserError)
from /usr/local/lib/ruby/2.1.0/json/common.rb:155:in `parse'
from /home/git/gitlab-shell/lib/gitlab_access_status.rb:13:in `create_from_json'
from /home/git/gitlab-shell/lib/gitlab_net.rb:34:in `check_access'
from /home/git/gitlab-shell/lib/gitlab_shell.rb:25:in `exec'
from /home/git/gitlab-shell/bin/gitlab-shell:16:in `<main>'
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Similar issue:
https://gitlab.com/gitlab-org/gitlab-ce/issues/838
It would appear that we have proper access via HTTPS and SSH, but something on the server, perhaps with git-shell is not right.
What we've done so far:
sudo -u git -H bundle exec rake gitlab:shell:setup RAILS_ENV=production
Made sure 'AllowUsers git' was in sshd_config
ssh-keygen -A
ssh-keygen: generating new host keys: ED25519
Tried different version of git-shell back to 2.2.0.
# ssh git#gitlab.domain.com
PTY allocation request failed on channel 0
Welcome to GitLab, Anonymous!
Connection to gitlab.domain.com closed.
As Geoff pointed out, my issue was a badly configured gitlab-shell/config.yml. Once the type for gitlab_url was corrected, we were able to push and pull without any issues with HTTPS and SSH.
I have a situation where I can checkout a repo through tortoise or Eclipse and a browser, but for the life of me cannot do it directly from the cygwin/ Linux command lines. These are the errors :
svn: E175002: Unable to connect to a repository at URL 'https://BLAH/project/trunk'
svn: E175002: OPTIONS of 'https://BLAH/project/trunk': could not connect to server (https://BLAH)
The command I use is :
svn checkout --username MYUN --password MYPASS https://BLAH/project/trunk
I have set the proxy too. Any ideas would be appreciated.
Regards
Try setting the proxy in ~/.subversion/servers.
On my corporate laptop behind a proxy that requires NTLM authentication I have to run the ntlmaps proxy and set:
Suppose you define them globally, add this at the end of the file:
http-proxy-host = localhost
http-proxy-port = 5865
I've configured the ntlmaps daemon to prompt me for my password but you could also add it to ~/.subversion/servers.
http-proxy-username = your account
http-proxy-password = your password
You can get ntlmaps from from http://ntlmaps.sourceforge.net/, extract it locally then edit ntlmaps-0.9.9\server.cfg
PARENT_PROXY:<server FQDN>
PARENT_PROXY_PORT:<proxy port>
NT_DOMAIN:<NT DOMAIN>
USER:<USERNAME>
PASSWORD:
Hope this helps.
Searching how to use git with a proxy I found two solutions:
the http_proxy environment variable
the git config http.proxy
Since export http_proxy=http://proxy.fqdn:8080 made wget work, but not git-svn, I tried the second option additionally: git config --global http.proxy http://proxy.fqdn:8080. But to no success. Wireshark still tells me that git-svn contacts the remote repository directly. Alas:
git svn clone -s http://svn.wp-plugins.org/yak-for-wordpress
ZM-Schicht Anforderung gescheitert: OPTIONS von »http://svn.wp-plugins.org/yak-for-wordpress«: Konnte keine Verbindung zum Server herstellen (http://svn.wp-plugins.org) at /usr/lib/git-core/git-svn line 1916
Am I missing something, or is this a bug in git-svn? Did anyone try successfuly to clone a svn repo through a proxy?
Make sure you don't have to specify your username and password as well (in addition to the proxy address).
But also consider adding that same information (http.proxy) to SVN itself (as in this thread):
Adding proxy information in the [global] section in $HOME/.subversion/servers fixed the issue.