每次操作完git clone都显示如下内容
Cloning into ‘xxxx’…
fatal: unable to access ‘.git/’: SSL certificate problem: unable to get local issuer certificate
包括git push以后也同样报错fatal:unable to…
这里提供一种解决错误的办法,符合条件即可使用
二者解决方式很接近,都是将后面粘贴的地址进行一些改动,所以不重复赘述,只说git clone时报错的解决办法。
$ git clone .git
Cloning into 'YOUR-REPOSITORY'...
fatal: unable to access '.git/': SSL certificate problem: unable to get local issuer certificate
当时网上很多操作都试过,大部分都是告诉我重新设置ssh key,但是我也配置过很多次,都仍然报错,后面自己通过Github官方文档查到了问题根源所在。
解决办法:
参考文档:
权限被拒绝(公钥)
SSH故障排除
本人是Windows11操作系统
先通过尝试尝试连接到 git@github 来检查使用的密钥:
在git bash中输入以下命令:
ssh -vT git@github
然后会出现一长串内容,我这里只留关键的几行:
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
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to ssh.github [20.205.243.160] port 443.
debug1: Connection established.
[ssh.github]:443 / (none)
debug1: client_input_hostkeys: searching /c/Users/89443/.ssh/known_hosts2 for [ssh.github]: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
可以看到其中几行
这里显示port 443,表示我们当前链接到Github是通过端口443进行链接。一般网络上提供的方法基本都是通过默认端口22进行链接,改端口太麻烦了于是我参考了官方文档SSH故障排除选择了一种更简捷有效的办法进行链接。
在 HTTPS 端口使用 SSH
有时,防火墙会完全拒绝允许 SSH 连接。
如果无法选择使用具有凭据缓存的 HTTPS 克隆,可以尝试使用通过 HTTPS 端口建立的 SSH 连接克隆。
大多数防火墙规则应允许此操作,但代理服务器可能会干扰。
输入以下命令:
$ ssh -T -p 443 git@ssh.github
若出现
> Hi USERNAME! You've successfully authenticated, but GitHub does not
> provide shell access.
则证明链接成功未被防火墙干扰。
要测试通过 HTTPS 端口的 SSH 是否可行,请运行以下 SSH 命令:
$ git clone ssh://git@ssh.github:443/YOUR-USERNAME/YOUR-REPOSITORY.git
注意:端口 443 的主机名为 ssh.github,而不是 github。
就是说把刚才的
$ git clone .git
改成
$ git clone ssh://git@ssh.github:443/YOUR-USERNAME/YOUR-REPOSITORY.git
即可使用。
Host github
Hostname ssh.github
Port 443
User git
如果还是不行请继续参考官方文档指南权限被拒绝(公钥)
本文发布于:2024-02-02 23:16:27,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170688698947098.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |