在 HTTPS 端口使用 SSH

73 阅读1分钟

最近由于不可描述的原因,本地无法正常 git push 提交代码。今天搜索到的一个好办法。

首先输入命令,测试是否可行。

ssh -T -p 443 git@ssh.github.com

如果返回了以下内容,则成功了。

1.png

下一步,开启设置。请在 ~/.ssh/config 编辑该文件,并添加以下部分:

Host github.com  
    Hostname ssh.github.com  
    Port 443
    User git

最后可以再次执行 ssh -T git@github.com 测试下

在切换到端口 443 后第一次与 GitHub 交互时,你可能会收到一条警告消息,指出在 known_hosts 中找不到主机,或者该主机由其他名称找到。提示

Are you sure you want to continue connecting (yes/no/[fingerprint])?

这里请回答 yes

参考资料:

docs.github.com/en/authenti…