29

I am running Ubuntu 18.04 LTS on armv7l. I am running git clone inside a proxy (I got the proxy variables set properly), but now I get this;

fatal: unable to access '<my_git>.git/': gnutls_handshake() failed: An unexpected TLS packet was received.

It used to work in Ubuntu 16.04. I have checked this solution but it does not work for me. All I am trying to do is to git clone.

Rock
  • 994
  • 1
  • 7
  • 12
  • You might want to have a look at [this question](https://stackoverflow.com/q/6178401/2311167) to help debugging the issue. Namely `GIT_TRACE_PACKET`. `GIT_CURL_VERBOSE=1` could also be helpful. Ary you using ssh or https? – Adrian W Jun 28 '18 at 18:58
  • Check @Nyambaa solution [here](https://askubuntu.com/questions/186847/error-gnutls-handshake-failed-when-connecting-to-https-servers) – Rohan Khude Aug 20 '18 at 07:11
  • @Rohan Khude please read the question again. Tried that before but only my answer works – Rock Aug 21 '18 at 22:48
  • Good work! Works for me on Debian 10. – Cinaed Simson Jun 11 '20 at 06:15

2 Answers2

59

Finally found the answer. It seems that I have to do:

git config --global http.proxy http://<my_proxy>:<my_port>
git config --global https.proxy https://<my_proxy>:<my_port>

Spent quick some time on this but luckily it works in the end. I thought this would be hard to fix but it turns out to be some commands that I never did before on Ubuntu 16.04.

Rock
  • 994
  • 1
  • 7
  • 12
8

Might be issue with gnutls Package. we have to compile a git Package with openssl instead of gnutls. Follow the below steps,

sudo apt-get install -y build-essential fakeroot dpkg-dev
sudo apt-get -y build-dep git
sudo apt-get install -y libcurl4-openssl-dev

mkdir git-openssl
cd git-openssl
apt-get source git
cd git-*
sed -i -e 's/libcurl4-gnutls-dev/libcurl4-openssl-dev/g' ./debian/control
sed -i -- '/TEST\s*=\s*test/d' ./debian/rules
sudo dpkg-buildpackage -rfakeroot -b
sudo dpkg -i git_2.7.4-0ubuntu1.6_arm64.deb

#CleanUp
cd ../../
sudo rm -rf git-openssl

You can follow This Bog or You can find simple script here to do that

kol
  • 27,881
  • 12
  • 83
  • 120
nullbyte91
  • 161
  • 2
  • 9
  • 1
    executing sudo apt-get install -y libcurl4-openssl-dev solved the issue for me. – fgamess Sep 16 '20 at 17:22
  • executing sudo apt-get install -y libcurl4-openssl-dev worked for me like a charm – Youssef Boudaya Apr 08 '21 at 11:22
  • ```sudo apt-get install -y build-essential fakeroot dpkg-dev ; sudo apt-get -y build-dep git ; sudo apt-get install -y libcurl4-openssl-dev``` did the trick! – Arnis Juraga Jul 27 '21 at 20:48
  • This worked for me. There is some issue in the git build given by apt as this happened for many users at my workplace who were using Ubuntu 20. The accepted answer is a very specific issue that was faced by the author (so for them, that was the correct answer). Many of us facing this issue might not be actually behind a proxy. – Anuj Kalra Mar 31 '22 at 05:56
  • 1
    Worked well for me :) but i had to run the following commands before sudo cp /etc/apt/sources.list /etc/apt/sources.list~ sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list sudo apt-get update inorder to get rid of the error E: You must put some 'source' URIs in your sources.list – Niel Jun 09 '22 at 05:38