简体   繁体   English

致命:无法访问“......”:gnutls_handshake()失败:握手失败

[英]fatal: unable to access ".....": gnutls_handshake() failed: Handshake failed

I've been using Git for the past few months.在过去的几个月里,我一直在使用 Git。 Recently when I try to clone or to push, I keep on getting this error.最近当我尝试克隆或推送时,我不断收到此错误。 I've researched on the inte.net but so far no solution has worked for me.我已经在 inte.net 上进行了研究,但到目前为止还没有对我有用的解决方案。 Does anyone have an idea?有人有想法吗?

External note: Now I moved to different country, it was working perfectly where I was before.外部说明:现在我搬到了不同的国家,它在我以前的地方工作得很好。 Git Version: 2.11.0, OS: Debian GNU/Linux 9.11 (stretch) Git 版本:2.11.0,操作系统:Debian GNU/Linux 9.11(拉伸)

Error:错误:

git push
fatal: unable to access 'https://**************/': gnutls_handshake() failed: Handshake failed

This is solution fix this issue on ubuntu server 14.04.x这是在 ubuntu 服务器 14.04.x 上解决此问题的解决方案

1, Edit file: 1、编辑文件:

sudo nano  /etc/apt/sources.list

2, Add to file sources.list 2、添加到文件sources.list

deb http://security.ubuntu.com/ubuntu xenial-security main
deb http://cz.archive.ubuntu.com/ubuntu xenial main universe

3, Run command update and update CURL to new version 3、运行命令 update 并将 CURL 更新到新版本

apt-get update && apt-get install curl

4, Check version (Optional): 4、检查版本(可选):

curl -V
Response :

curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.28 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets 

5, Test connect with bitbucket (Optional) 5、用bitbucket测试连接(可选)

GIT_CURL_VERBOSE=1 git ls-remote https://bitbucket.org/
Response:


* Closing connection 0
fatal: repository 'https://bitbucket.org/' not found

This done.这完成了。

I also incurred this problem with Ubuntu 14.04 LTS.我在 Ubuntu 14.04 LTS 上也遇到了这个问题。 Quickest solution is to use ssh instead of https.最快的解决方案是使用 ssh 而不是 https。 Following are steps to replace https from ssh:以下是从 ssh 替换 https 的步骤:

  1. Generate ssh key using ssh-keygen on the server.在服务器上使用 ssh-keygen 生成 ssh 密钥

  2. Copy public key from generated id_rsa.pub file from step 1 and add it at following links depending on repository host -从步骤 1 生成的 id_rsa.pub 文件中复制公钥,并将其添加到以下链接中,具体取决于存储库主机 -

    Bitbucket - https://bitbucket.org/account/settings/ssh-keys/ Bitbucket - https://bitbucket.org/account/settings/ssh-keys/

    Github - https://github.com/settings/ssh/new Github - https://github.com/settings/ssh/new

    Gitlab - https://gitlab.com/profile/keys Gitlab - https://gitlab.com/profile/keys

  3. Now run following command to test authentication from server command line terminal现在运行以下命令以从服务器命令行终端测试身份验证

    Bitbucket比特桶

    ssh -T git@bitbucket.org
    Github Github
     ssh -T git@github.com
    Gitlab GitLab
     ssh -T git@gitlab.com

  4. Go to repo directory and open .git/config file using emac or vi转到 repo 目录并使用 emac 或 vi 打开 .git/config 文件

  5. Replace remote "origin" url (which starts with https) with following -将远程“原始”网址(以 https 开头)替换为以下内容 -

    For Bitbucket - git@bitbucket.org:<username>/<repo>.git对于 Bitbucket - git@bitbucket.org:<username>/<repo>.git

    For Github - git@github.com:<username>/<repo>.git对于 Github - git@github.com:<username>/<repo>.git

    For Gitlab - git@gitlab.com:<username>/<repo>.git对于 Gitlab - git@gitlab.com:<username>/<repo>.git

This error means that Git cannot establish a secure connection to the server you're trying to use.此错误意味着 Git 无法与您尝试使用的服务器建立安全连接。 Your version of Git uses the GnuTLS library to set up TLS (encrypted) connections, and for some reason that setup process is failing.您的 Git 版本使用 GnuTLS 库来设置 TLS(加密)连接,并且由于某种原因设置过程失败。

This could be for a couple of reasons.这可能有几个原因。 One is that your server (which one you haven't mentioned) is using an incompatible set of cipher suites or TLS versions, and there's no encryption algorithms in common that can be chosen.一个是您的服务器(您没有提到的那个)正在使用一组不兼容的密码套件或 TLS 版本,并且没有可以选择的通用加密算法。 It's also possible that you have someone tampering with the connection via a MITM device.也有可能有人通过 MITM 设备篡改了连接。

The version of Git and GnuTLS you're using should work just fine with most standard servers.您使用的 Git 和 GnuTLS 版本应该可以在大多数标准服务器上正常工作。 Re-installing it won't help.重新安装它不会有帮助。 You can try upgrading to a newer version of Debian, or you can try building Git yourself against a version of libcurl using OpenSSL.您可以尝试升级到较新版本的 Debian,或者您可以尝试使用 OpenSSL 针对 libcurl 版本自己构建 Git。 You can also just switch to SSH-based remotes, which will avoid this incompatibility altogether.您也可以只切换到基于 SSH 的远程,这将完全避免这种不兼容。

I got the same error.我得到了同样的错误。

You could try to compile git with OpenSSL instead of gnutls using Paul N. Baker's shell script .您可以尝试使用Paul N. Baker 的 shell script使用 OpenSSL 而不是 gnutls 编译 git。

  1. Create file.sh创建file.sh
  2. Put the code of the link into this file把链接的代码放到这个文件中
  3. Give permission to this file: chmod a+x file.sh授予此文件的权限: chmod a+x file.sh
  4. Run: sudo ./file.sh运行: sudo ./file.sh

This shell script works for me.这个 shell 脚本对我有用。

It might be only a part of the problem.这可能只是问题的一部分。 How about other https sites?其他 https 网站怎么样? How are you connected to the inte.net?您是如何连接到 inte.net 的? Is your git counterpart is reachable through VPN?您的 git 对方是否可以通过 VPN 访问?

Why am I asking?我为什么要问? I faced the same problem: Git is used in Ubuntu 22.04 VM hosted in Windows 10 Hyper-X.我遇到了同样的问题:Git 在 Windows 10 Hyper-X 中托管的 Ubuntu 22.04 VM 中使用。 VM is connected to the Inte.net trough Default Switch (NAT) and shares OpenConnect VPN connection of the host. VM 通过默认交换机 (NAT) 连接到 Inte.net 并共享主机的 OpenConnect VPN 连接。

One day git failed to fetch from remote repo that was located in private.network that is reachable through VPN.有一天git未能从位于 private.network 中的远程仓库中获取数据,该网络可通过 VPN 访问。 Symptoms were like yours:症状和你一样:

gnutls_handshake() failed gnutls_handshake() 失败

After some investigation I found next facts:经过一番调查,我发现了下一个事实:

  1. All https resources that were reachable through VPN were ping-able with default presets from guest, but Https connection to them could not be established通过 VPN 可访问的所有 https 资源都可以使用来宾的默认预设 ping 通,但无法建立与它们的 Https 连接
  2. Other https resources that were not under VPN were reachable and were working normally其他 https 不在 VPN 下的资源可以访问并且工作正常
  3. While connection attempts to https resources with firefox browser I found some bad packets report in OpenConnect-GUI VPN Client Log: OpenConnect Log window当尝试使用 firefox 浏览器连接到 https 资源时,我在 OpenConnect-GUI VPN 客户端日志中发现了一些错误数据包报告: OpenConnect Log window

After that I tried to trace path to remote git repo: tracepath-screenshot之后我尝试追踪到远程 git 回购的路径: tracepath-screenshot

developer@Ubuntu-VM:~$ tracepath **.**.167.240 -n
 1?: [LOCALHOST]                      pmtu 1500
 1:  172.18.224.1                                          0.485ms 
 1:  172.18.224.1                                          0.386ms 
 2:  172.18.224.1                                          0.227ms pmtu 1290
 2:  **.**.254.9                                          38.242ms 
 3:  **.**.30.14                                          32.438ms 
 4:  **.**.167.240                                        32.136ms reached
     Resume: pmtu 1290 hops 4 back 4 

Where I've noticed some pmtu strings in the right side of the screen and a final Resume note.我注意到屏幕右侧有一些pmtu字符串和最后的简历注释。

So, I decided to check MTU preset for my.network interface: ifconfig-screenshot所以,我决定检查 my.network 接口的 MTU 预设: ifconfig-screenshot

developer@Ubuntu-VM:~$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.227.200  netmask 255.255.240.0  broadcast 172.18.239.255
        inet6 fe80::d1b:9e02:3919:d75b  prefixlen 64  scopeid 0x20<link>
        ether 00:15:5d:19:76:00  txqueuelen 1000  (Ethernet)
        RX packets 56234  bytes 311928403 (311.9 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13927  bytes 1148583 (1.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

as you can see, interface eth0 had MTU 1500 (... that was too much for current VPN tunnel).如您所见,接口 eth0 的MTU 为 1500 (...对于当前的 VPN 隧道来说太多了)。

When I've changed eth0 MTU to 1290, as suggested tracepath utility:当我按照tracepath实用程序的建议将 eth0 MTU 更改为 1290 时:

sudo ifconfig eth0 mtu 1290

my problem was solved.我的问题解决了。 (MTU has to be also changed in Ubuntu.network setup settings page to take permanent effect) (MTU 也必须在 Ubuntu.network 设置页面中更改才能永久生效)

Profit!利润!

Read also: Windows WSL: Git and gnutls_handshake() failed另请阅读: Windows WSL:Git 和 gnutls_handshake() 失败

I figure it by我认为它是

git config --global --unset https.proxy
git config --global --unset http.proxy 

even though I try即使我尝试

git config --global --get https.proxy
git config --global --get http.proxy 

don't show any results, but unset https.proxy still work.不显示任何结果,但未设置 https.proxy 仍然有效。

如果您使用的是 Ubuntu 20.04,使用个人计算机(未配置代理),那么只需将您的gnutls-bin更新到最新版本

sudo apt-get install gnutls-bin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 git clone:致命:gnutls_handshake()失败了 - git clone: fatal: gnutls_handshake() failed Ubuntu git:致命:无法访问 gnutls_handshake() 失败:已收到 TLS 致命警报 - Ubuntu git: fatal: unable to access gnutls_handshake() failed: A TLS fatal alert has been received Github无法访问... gnutls_handshake()失败:关闭通知 - Github unable to access… gnutls_handshake() failed:Close notify gnutls_handshake() 失败:GIT 握手失败 - gnutls_handshake() failed: Handshake failed GIT Git,致命:无法访问“https://github.com/path/to/repo.git”:gnutls_handshake() 失败:pull 函数出错 - Git, fatal: unable to access 'https://github.com/path/to/repo.git': gnutls_handshake() failed: Error in the pull function git错误:gnutls_handshake()在推送时失败 - git error: gnutls_handshake() failed on push 错误:gnutls_handshake()GIT存储库失败 - error: gnutls_handshake() failed GIT repository git失败,并显示“ gnutls_handshake()失败” - git fails with “gnutls_handshake() failed” “gnutls_handshake()失败():一个意外长度的TLS数据包”在学校收到“ - “gnutls_handshake() failed(): A TLS packet with unexpected length was receive” at school Git 问题:gnutls_handshake() 失败:收到了意外的 TLS 数据包 - Git Problem: gnutls_handshake() failed: An unexpected TLS packet was received
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM