Can't clone a github repo on Linux via HTTPS
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.
Can't clone private Github repositories over HTTPS
You can clone your repository with:
git clone https://username@github.com/username/repo_name
It can also help to check your git configuration with:
git config -l
Can't clone any repository using git
That error is clearly described in HTTPS cloning errors
Depending on the exact error message, trying to clone with your username in the url can help:
git clone https://<username>@github.com/<username>/<repo.git>
But ideally, you should recompile and install a more recent version of Git.
With Git version 2.12.0, the error message is:
fatal: unable to access 'https://github.com/creationix/nvm.git/':
Problem with the SSL CA cert
Make sure you have installed the certificates:
sudo yum reinstall openssl ca-certificates -y
The manual version of this fix is:
mkdir -p /etc/pki/tls/certs
curl https://curl.haxx.se/ca/cacert.pem -o /etc/pki/tls/ca-bundle.crt
git config --global http.sslcainfo /etc/pki/tls/ca-bundle.crt
git config -l
Another approach is described here:
mkdir /usr/src/ca-certificates && cd /usr/src/ca-certificates
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/ca-certificates-2015.2.6-65.0.1.el6_7.noarch.rpm
rpm2cpio ca-certificates-2015.2.6-65.0.1.el6_7.noarch.rpm | cpio -idmv
cp -pi ./etc/pki/tls/certs/ca-bundle.* /etc/pki/tls/certs/
Note: edtech adds in the comments:
Upgrading the
nss
package (yum update nss
) has solved the same problem for me.
Can't clone repo using git clone git://... - ok with git clone http://
Well, I think you are using the wrong url in your second case
Try this instead
git clone git@github.com:organisation_name/repo_name.git
The difference is the :
in the url when using git@
vs the /
you are currently using, and the extra .git
at the end.
This should be the same url if you go to github and select the ssh url for cloning (and not the https one selected by default)
git clone with https error - fatal: repository not found
This Github document reads:
The
https://
clone URLs are available on all repositories, public and private.
But since you are trying to access a private repository, authentication is required. One way is appending username and password the address as below:
git clone https://username:password@github.com/usernamex/privat-repo.git
But the same page reads:
If you have enabled two-factor authentication, or if you are accessing an organization that uses SAML single sign-on (SSO), you must authenticate with a personal access token instead of your username and password for GitHub.
If you have 2FA enabled, check this page for steps to generate a personal access token. Bear in mind that you should check full repo
scope (as shown below) for your personal token.
Git Clone - Repository not found
If you are using two factor authorization (2FA) for your Github account then just use SSH option for cloning your repository:
Clone A Private Repository (Github)
Private clone URLs take the form git@github.com:username/repo.git
- perhaps you needed to use git@
rather than git://
?
git://
URLs are read only, and it looks like private repos do not allow this form of access.
Related Topics
How to Create a Link to a Directory
How to Get Position of Cursor in Terminal
How to Convert Yyyymmddhhmmss to a Date Readable by 'Date'
Linux Vi Arrow Keys Broken in Insert Mode
Grep a Large List Against a Large File
Does Gcc Have Any Options to Add Version Info in Elf Binary File
Docker: Are Docker Links Deprecated
Http Post and Get Using Curl in Linux
Sending a Mail from a Linux Shell Script
Restarting Cron After Changing Crontab File
Faster Forking of Large Processes on Linux
Self Modifying Code Always Segmentation Faults on Linux
Why Does Printf Overwrite the Ecx Register
Why Do We Need a Bootloader in an Embedded Device
How to Undo Strip - I.E. Add Symbols Back to Stripped Binary