git操作通過https鏈接從Github克隆倉庫到本地總報錯(Windows11)并且重新設(shè)置ssh key也沒用的情況下
每次操作完git clone都顯示如下內(nèi)容
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…
這里提供一種解決錯誤的辦法,符合條件即可使用
二者解決方式很接近,都是將后面粘貼的地址進(jìn)行一些改動,所以不重復(fù)贅述,只說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
當(dāng)時網(wǎng)上很多操作都試過,大部分都是告訴我重新設(shè)置ssh key,但是我也配置過很多次,都仍然報錯,后面自己通過Github官方文檔查到了問題根源所在。
解決辦法:
參考文檔:
權(quán)限被拒絕(公鑰)
SSH故障排除
本人是Windows11操作系統(tǒng)
先通過嘗試嘗試連接到 git@github.com 來檢查使用的密鑰:
在git bash中輸入以下命令:
ssh -vT git@github.com
然后會出現(xiàn)一長串內(nèi)容,我這里只留關(guān)鍵的幾行:
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
可以看到其中幾行
這里顯示port 443,表示我們當(dāng)前鏈接到Github是通過端口443進(jìn)行鏈接。一般網(wǎng)絡(luò)上提供的方法基本都是通過默認(rèn)端口22進(jìn)行鏈接,改端口太麻煩了于是我參考了官方文檔SSH故障排除選擇了一種更簡捷有效的辦法進(jìn)行鏈接。
在 HTTPS 端口使用 SSH
有時,防火墻會完全拒絕允許 SSH 連接。
如果無法選擇使用具有憑據(jù)緩存的 HTTPS 克隆,可以嘗試使用通過 HTTPS 端口建立的 SSH 連接克隆。
大多數(shù)防火墻規(guī)則應(yīng)允許此操作,但代理服務(wù)器可能會干擾。
輸入以下命令:
$ ssh -T -p 443 git@ssh.github.com
若出現(xiàn)
> 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 的主機(jī)名為 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
即可使用。文章來源:http://www.zghlxwxcb.cn/news/detail-444728.html
Host github.com
Hostname ssh.github.com
Port 443
User git
如果還是不行請繼續(xù)參考官方文檔指南權(quán)限被拒絕(公鑰)文章來源地址http://www.zghlxwxcb.cn/news/detail-444728.html
到了這里,關(guān)于git操作出錯顯示fatal: unable to access ‘https://github.com/xxxx/xxxx.git/‘: SSL certificate problem:的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!