ssh: connect to host github.com port 22: Resource temporarily unavailable

文章目录

    从昨天晚上开始,发现无法直接拉取 github 上的代码仓库了。报错如下:

    ssh: connect to host github.com port 22: Resource temporarily unavailable
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    

    我以为我的 github 账号权限出了问题。

    但是换成 https 协议,会报:

    Failed to connect to github.com port 443: Connection refused

    说明还是网络问题。

    判断 github 的 DNS 解析问题

    > nslookup github.com
    Server:         114.114.114.114
    Address:        114.114.114.114#53
    
    Non-authoritative answer:
    Name:   github.com
    Address: 20.205.243.166
    

    参考:

    https://www.v2ex.com/t/1009169

    GitHub 在国内会被解析到新加坡节点的 20.205.243.166 ,这个 IP 在全国范围内被空路由了,其他 GitHub 的 IP 暂时没事,也可能只是策略还没分发完毕

    解决方案

    打开配置文件 ~/.ssh/config 添加:

    # add
    Host github.com
      Hostname ssh.github.com
      Port 443
    

    然后,就能正常的拉取 github 代码了。

    在国内写代码太痛苦了,搞得跟个小偷一样 🤣

    关于作者 🌱

    我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊,或者关注我的个人公众号“大象工具”, 查看更多联系方式