title: >- [GitHub] fatal: unable to access 'https://github.com/': Failed to connect to github.com port 443: Operation timed out tags: [github,git] categories: github url: https://www.carlzeng.top date: 2021-11-23 11:11:00
解決Github連接錯誤的思路 由於眾所周知的緣故,連接到github越來越微妙,分享一些MAC平台上的解決思路,希望對你有幫助: <!-- more -->
最新方案(2023年11月)
超級好用的命令行走代理方式: HTTPS_PROXY="socks5://127.0.0.1:7890" git clone https://github.com/rustdesk/rustdesk
然后結合Clash For Window的 url-test 模式,選用最快的服務器;測試結果很滿意: HTTPS_PROXY="socks5://127.0.0.1:7890" git clone https://github.com/rustdesk/rustdesk Cloning into 'rustdesk'... remote: Enumerating objects: 59934, done. remote: Counting objects: 100% (14388/14388), done. remote: Compressing objects: 100% (326/326), done. remote: Total 59934 (delta 14161), reused 14065 (delta 14062), pack-reused 45546 Receiving objects: 100% (59934/59934), 40.41 MiB | 956.00 KiB/s, done. Resolving deltas: 100% (45272/45272), done.
單線程下載,平均速度達到1M/s左右;挺滿意了
Errors
-
fatal: unable to access 'https://github.com/': Failed to connect to github.com port 443: Operation timed out
-
fatal: Authentication failed for 'https://github.com/'
-
fatal unable to access https://github.com LibreSSL SSL_connect SSL_ERROR_SYSCALL in connection to github.com 443
Notes:
Don't verify the operation in editor(WebStorm,IntelliJ IDEA...etc), use command(Mac's terminal.app), use terminal.app
Solutions for: Operation timed out
-
Fix the hosts to make sure the ssh connection between your Computer and github.com is availble(修復連接到github.com)
Verify Standard 判斷標准:$ ssh -T git@github.com
1.1 記錄下github的IP地址, 把IP Address 記錄下來
打開https://github.com.ipaddress.com/
打開https://fastly.net.ipaddress.com/github.global.ssl.fastly.net#ipinfo
打開https://github.com.ipaddress.com/assets-cdn.github.com
1.2 打開電腦的hosts文件(/private/etc/hosts),把下列的地址對應寫入,然后保存即可(version2021.11.23)
# Github Start. Updated 20211123/CZ 140.82.113.3 github.com 199.232.69.194 github.global.ssl.fastly.net 185.199.108.153 assets-cdn.github.com 185.199.109.153 assets-cdn.github.com 185.199.110.153 assets-cdn.github.com 185.199.111.153 assets-cdn.github.com
Github End
1.3 在終端在輸以下指令刷新DNS(需要權限)
sudo killall -HUP mDNSResponder
1.4 如果之前用ssh proxy,取消它
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy http://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
1.5 重新嘗試 ping github.com. 重新嘗試 ssh -T git@github.com
新的錯誤可能和授權有關,至少證明連接到github.com是通的。
Solutions for: Authentication
-
Create new Token and login to github.com (新建密鑰並登陸進github.com)
Verify Standard 判斷標准:$ git pull
2.1 Creating a personal access token at https://github.com/settings/tokens
授權_admin:org, admin:public_key, admin:repo_hook, gist, read:user, repo, _write:packages__
2.2 Terminal.app 命令行,運行 git pull(先要cd 到原來的git 根目錄)
Username for 'https://github.com': (這個地方輸入登錄github網址用的用戶名,我的是用9個英文字母) Password for 'https://***@github.com': (這個地方要是輸入#2.1中得到的Token)
2.3 判斷一下連接和授權,如果需要ssh連接,繼續添加配置以下。
2.4 生成ssh密鑰。Generating a new SSH key and adding it to the ssh-agent。具體步驟簡要如下:
$ ssh-keygen -t ed25519 -C "your\_email@example.com"
> Enter a file in which to save the key (/Users/you/.ssh/id\_algorithm): \[Press enter\] \> Enter passphrase (empty for no passphrase): \[Type a passphrase\] \> Enter same passphrase again: \[Type passphrase again\] \---------------------------------------------------- $ eval "$(ssh-agent -s)"
> Agent pid 59566
---------------------------------------------------- $ touch ~/.ssh/config
加入以下內容:
Host \* AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id\_ed25519 \---------------------------------------------------- $ ssh\-add -K ~/.ssh/id\_ed25519
2.5 協助排查:github服務端的日志,顯示有用的連接信息,用來驗證鏈路是否握手成功等等
https://github.com/settings/security-log
盡量把驗證都放在命令行中,這樣更高效直接(在IDE中操作,在驗證太費勁了),terminal成功以后,IDEA會自動也成功,因為它們分享相同的配置(git 根目錄下面有.git的配置目錄)
參見文檔:
https://juejin.cn/post/6844904193170341896
https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
Node.js也被同樣錯誤卡
hexo d ... fatal: unable to access 'https://github.com/@@@@@.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html ...
{% tabs 嘗試%} <!-- tab -->
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890
重試hexo d <!-- endtab -->
<!-- tab -->
git config --global --unset http.proxy
git config --global --unset https.proxy
重試hexo d 有的時候很奇怪:非要先proxy以后重試失敗,然后在這樣--unset以后重試,就能成功。 具體錯誤內容 fatal: unable to access 'https://github.com/@@@@@@.git/': LibreSSL SSL_connect: Connection reset by peer in connection to github.com:443
<!-- endtab --> {% endtabs %}
解決辦法后來是因為hexo沒有檢測到內容變動,不去push。 hexo clean 然后在 hexo g && hexo d 就解決了
hexo d 更新的解決辦法
運行命令行當時輸入:
HTTPS_PROXY="socks5://127.0.0.1:7890" hexo g && hexo d
這樣省去了來回切換的麻煩步驟。
思路:當Github源連同賬號被刪除后
-
緩存,當Github源連同賬號被刪除后,用CDN可以繼續訪問到
【已失效用下面的CDN緩存替換】curl -fksSL https://github.com/lmq8267/567/releases/download/scriptfile/install1.10.3.sh | sh
發現一個CDN的優點:當緩存完成后源站點內容被刪除,CDN還是會保存着內容;也就是說這個同步是單方向的。
curl -fkSL https://fastly.jsdelivr.net/gh/lmq8267/ZeroTierOne@master/install/installzero.sh | sh
-
還有一個思路:hub.docker.com docker部署的緩存,仍然可以在一段時間內有效 比如:https://hub.docker.com/r/dreamacro/clash
-
2021年11月,由於天朝眾所周知的緣故,連接到github越來越微妙,分享一些MAC平台上的解題思路,希望對你有幫助:
Errors
- fatal: unable to access 'https://github.com/': Failed to connect to github.com port 443: Operation timed out
- fatal: Authentication failed for 'https://github.com/'
- fatal unable to access https://github.com LibreSSL SSL_connect SSL_ERROR_SYSCALL in connection to github.com 443
Notes:
Don't verify the operation in editor(WebStorm,IntelliJ IDEA...etc), use command(Mac's terminal.app), use terminal.app
Solutions for: Operation timed out
1. Fix the hosts to make sure the ssh connection between your Computer and github.com is availble(修復連接到github.com)
Verify Standard 判斷標准:$ ssh -T git@github.com
1.1 記錄下github的IP地址, 把IP Address 記錄下來
打開https://github.com.ipaddress.com/
打開https://fastly.net.ipaddress.com/github.global.ssl.fastly.net#ipinfo
打開https://github.com.ipaddress.com/assets-cdn.github.com
1.2 打開電腦的hosts文件(/private/etc/hosts),把下列的地址對應寫入,然后保存即可(version2021.11.23)
# Github Start. Updated 20211123/CZ 140.82.113.3 github.com 199.232.69.194 github.global.ssl.fastly.net 185.199.108.153 assets-cdn.github.com 185.199.109.153 assets-cdn.github.com 185.199.110.153 assets-cdn.github.com 185.199.111.153 assets-cdn.github.com # Github End
1.3 在終端在輸以下指令刷新DNS(需要權限)
sudo killall -HUP mDNSResponder
1.4 如果之前用ssh proxy,取消它
git config --global http.proxy http://127.0.0.1:1080 git config --global https.proxy http://127.0.0.1:1080 git config --global --unset http.proxy git config --global --unset https.proxy
1.5 重新嘗試 ping github.com. 重新嘗試 ssh -T git@github.com
新的錯誤可能和授權有關,至少證明連接到github.com是通的。
Solutions for: Authentication
2. Create new Token and login to github.com (新建密鑰並登陸進github.com)
Verify Standard 判斷標准:$ git pull
2.1 Creating a personal access token at https://github.com/settings/tokens
授權admin:org, admin:public_key, admin:repo_hook, gist, read:user, repo, write:packages
具體步驟:https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
2.2 Terminal.app 命令行,運行 git pull(先要cd 到原來的git 根目錄)
Username for 'https://github.com': (這個地方輸入登錄github網址用的用戶名,我的是用9個英文字母)
Password for 'https://***@github.com': (這個地方要是輸入#2.1中得到的Token)
2.3 判斷一下連接和授權,如果需要ssh連接,繼續添加配置以下。
2.4 生成ssh密鑰。Generating a new SSH key and adding it to the ssh-agent。具體步驟簡要如下:
$ ssh-keygen -t ed25519 -C "your_email@example.com" > Enter a file in which to save the key (/Users/you/.ssh/id_algorithm): [Press enter] > Enter passphrase (empty for no passphrase): [Type a passphrase] > Enter same passphrase again: [Type passphrase again] ---------------------------------------------------- $ eval "$(ssh-agent -s)" > Agent pid 59566 ---------------------------------------------------- $ touch ~/.ssh/config 加入以下內容: Host * AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_ed25519 ---------------------------------------------------- $ ssh-add -K ~/.ssh/id_ed25519
2.5 協助排查:github服務端的日志,顯示有用的連接信息,用來驗證鏈路是否握手成功等等
https://github.com/settings/security-log
盡量把驗證都放在命令行中,這樣更高效直接(在IDE中操作,在驗證太費勁了),terminal成功以后,IDEA會自動也成功,因為它們分享相同的配置(git 根目錄下面有.git的配置目錄)
參見文檔:
https://juejin.cn/post/6844904193170341896
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
