git操作出错显示fatal: unable to access ‘https://github.com/xxxx/xxxx.git/‘: SSL certificate problem:

这篇具有很好参考价值的文章主要介绍了git操作出错显示fatal: unable to access ‘https://github.com/xxxx/xxxx.git/‘: SSL certificate problem:。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

git操作通过https链接从Github克隆仓库到本地总报错(Windows11)并且重新设置ssh key也没用的情况下

每次操作完git clone都显示如下内容
Cloning into ‘xxxx’…
fatal: unable to access ‘https://github.com/YOUR-USERNAME/YOUR-REPOSITORY.git/’: SSL certificate problem: unable to get local issuer certificate
包括git push以后也同样报错fatal:unable to…
这里提供一种解决错误的办法,符合条件即可使用

二者解决方式很接近,都是将后面粘贴的地址进行一些改动,所以不重复赘述,只说git clone时报错的解决办法。

$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY.git
Cloning into 'YOUR-REPOSITORY'...
fatal: unable to access 'https://github.com/YOUR-USERNAME/YOUR-REPOSITORY.git/': SSL certificate problem: unable to get local issuer certificate

当时网上很多操作都试过,大部分都是告诉我重新设置ssh key,但是我也配置过很多次,都仍然报错,后面自己通过Github官方文档查到了问题根源所在。
解决办法:
参考文档:
权限被拒绝(公钥)
SSH故障排除
本人是Windows11操作系统
先通过尝试尝试连接到 git@github.com 来检查使用的密钥:
在git bash中输入以下命令:

ssh -vT git@github.com

然后会出现一长串内容,我这里只留关键的几行:

OpenSSH_9.1p1, OpenSSL 1.1.1s  1 Nov 2022
debug1: Reading configuration data /c/Users/xxxxx/.ssh/config
debug1: /c/Users/89443/.ssh/config line 1: Applying options for github.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to ssh.github.com [20.205.243.160] port 443.
debug1: Connection established.
[ssh.github.com]:443 / (none)
debug1: client_input_hostkeys: searching /c/Users/89443/.ssh/known_hosts2 for [ssh.github.com]:443 / (none)
debug1: client_input_hostkeys: hostkeys file /c/Users/89443/.ssh/known_hosts2 does not exist
debug1: client_input_hostkeys: no new or deprecated keys from server
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi kxjh990528! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2104, received 2344 bytes, in 0.6 seconds
Bytes per second: sent 3488.6, received 3886.5
debug1: Exit status 1

可以看到其中几行
git操作出错显示fatal: unable to access ‘https://github.com/xxxx/xxxx.git/‘: SSL certificate problem:
这里显示port 443,表示我们当前链接到Github是通过端口443进行链接。一般网络上提供的方法基本都是通过默认端口22进行链接,改端口太麻烦了于是我参考了官方文档SSH故障排除选择了一种更简捷有效的办法进行链接。
在 HTTPS 端口使用 SSH
有时,防火墙会完全拒绝允许 SSH 连接。
如果无法选择使用具有凭据缓存的 HTTPS 克隆,可以尝试使用通过 HTTPS 端口建立的 SSH 连接克隆。
大多数防火墙规则应允许此操作,但代理服务器可能会干扰。
输入以下命令:

$ ssh -T -p 443 git@ssh.github.com

若出现

> Hi USERNAME! You've successfully authenticated, but GitHub does not
> provide shell access.

则证明链接成功未被防火墙干扰。
要测试通过 HTTPS 端口的 SSH 是否可行,请运行以下 SSH 命令:

$ git clone ssh://git@ssh.github.com:443/YOUR-USERNAME/YOUR-REPOSITORY.git

注意:端口 443 的主机名为 ssh.github.com,而不是 github.com。
就是说把刚才的

$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY.git

改成

$ git clone ssh://git@ssh.github.com:443/YOUR-USERNAME/YOUR-REPOSITORY.git

即可使用。

Host github.com
Hostname ssh.github.com
Port 443
User git

如果还是不行请继续参考官方文档指南权限被拒绝(公钥)文章来源地址https://www.toymoban.com/news/detail-444728.html

到了这里,关于git操作出错显示fatal: unable to access ‘https://github.com/xxxx/xxxx.git/‘: SSL certificate problem:的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包