codedecoder

breaking into the unknown…


Leave a comment

git clone problem

Recently, I am asked to create a staging instance for our project, with exact same copy of environment as of production, so that code can be tested in exact environment before deploying on production. I was given ssh access to the new server space. When, I clone the repository on my local machine, it prompt me to enter my github username and password, and on authentication clone the repository.

But, when I tried to clone the repository, after login to the new server, I get into trouble, failing to clone it with every possible way I know.

=> Tried with https url
# git clone https://github.com/my-finance/customer-portal.git cportal
Cloning into cportal…
error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/ThirdPillar/cportal.git/info/refs
fatal: HTTP request failed

=> Tried with simple http url
# git clone http://github.com/my-finance/customer-portal.git cportal
Cloning into cportal…
(gnome-ssh-askpass:5068): Gtk-WARNING **: cannot open display:

=> Tried with ssh url
# git clone git@github.com:/my-finance/customer-portal.git cportal
Cloning into cportal…
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly.

O.K, so I understand the problem in first case, providing https in git url, means Git is expecting ssl certificate to be present on the machine trying to clone the repo. The new server do not have any ssl certificate so, it is failing. I have reported to client to purchase the certificate and add it to the new server.

In second case i,e with http , git try to secure the cloning by asking the repository username and password, but in my case the prompt to enter username and password is not appearing, so I ‘am struck up again.

I do not know the third problem i,e why with ssh url of the repository, it is saying Repository not found . Many a time I have cloned git repository with there ssh URL, but this time it is not working.

Searching a lot, finally, I got solution in this stackoverflow thread . It is long thread, with different people suggesting different things, but is worth reading.

Basically, in this case, my solution is to tell git to not verify the SSl certificate and do authentication with username password

1 : do not verfiy SSL certificate

NOTE : I have used it for temporary workaround. do not disable SSl verification, it will risk your repository. The correct solution is to add the SSl certificate on the machine

It can be done by running any of the below two commands :

export GIT_SSL_NO_VERIFY=false #export is linux command which can set any variable from the command line

OR
git config –global http.sslVerify false

they will tell GIt to not verify SSL certificate while, cloning, pulling or pushing over https connection.
  2: enable the password prompt

The password prompt is having some value set, which is preventing it to appear. we need to remove that. jut opposite to export command which set a variable, unset will remove that variable. So below command should be used.

unset SSH_ASKPASS

Reference:

https://github.com/hbons/SparkleShare/issues/1136

http://stackoverflow.com/questions/9364901/git-push-doesnt-ask-for-password-and-gives-401-fine-when-password-typed-inline

https://www.kernel.org/pub/software/scm/git/docs/v1.7.3/git-config.html

http://www.tldp.org/HOWTO/SSL-Certificates-HOWTO/x64.html
http://www.sslshopper.com/what-is-ssl.html
http://www.sslshopper.com/why-ssl-the-purpose-of-using-ssl-certificates.html