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

发布时间:2024年01月19日

背景

可能是中国内地网络环境的原因,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.

通过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/'

解决

官方文档: 在 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

文章来源:https://blog.csdn.net/u010834463/article/details/135697978
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。