当前位置:   article > 正文

Git推送到Guthub错误:ssh: connect to host github.com port 22: Connection refused

Git推送到Guthub错误:ssh: connect to host github.com port 22: Connection refused

背景

可能是中国内地网络环境的原因,Git通过ssh推送到自己的存储库发生以下错误。大概是github.com的22端口被屏蔽了?

root@yst-ubuntu:~/dev-chaos-test-system/chaos-test-system# git push origin dev
ssh: connect to host github.com port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

通过HTTPS也不行,以下错误提示大意是 2021-08-13 密码认证被移除了。官方中文文档 文档里似乎没说密码认证被移除这回事

root@yst-ubuntu:~/dev-chaos-test-system/chaos-test-system# git push hub_https dev
Username for 'https://github.com': YuSitong1999
Password for 'https://YuSitong1999@github.com': 
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/YuSitong1999/chaos-test-system.git/'

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

解决

官方文档: 在 HTTPS 端口使用 SSH

链接格式和GitHub提供的前两条HTTPS和SSH链接不一样。

https://github.com/YuSitong1999/chaos-test-system.git
git@github.com:YuSitong1999/chaos-test-system.git

ssh://git@ssh.github.com:443/YuSitong1999/chaos-test-system.git

  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/480300
推荐阅读
相关标签
  

闽ICP备14008679号