[GitHub] fatal: unable to access 'https://github.com/': Failed to connect to github.com port 443: Operation timed out

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

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

  1. 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/

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

 

 

 

 

 

 





 


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/

 

posted @ 2021-11-23 11:11  CarlZeng  阅读(6839)  评论(0编辑  收藏  举报