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.

通过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://[email protected]': 
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
[email protected]:YuSitong1999/chaos-test-system.git

ssh://[email protected]:443/YuSitong1999/chaos-test-system.git

你可能感兴趣的:(git,git,ssh,github)