接上篇“Ubuntu在GitHub中配置SSH Key”,在 配置了公钥之后我们应该是可以通过SSH方式直接上传或下载github上的仓库的,但是在实际使用过程中由于用了梯子,导致不能使用ssh的方式登录github,还是提示要输入密码git@github.com‘s password: ,没有达到我们想要的效果。
解决方案:
- 测试通过 HTTPS 端口的 SSH 是否可行:
$ ssh -T -p 443 git@ssh.github.com
> Hi username! You've successfully authenticated, but GitHub does not
> provide shell access.
- 启用通过 HTTPS 的 SSH 连接
如果你能在端口 443 上通过 SSH 连接到 git@ssh.github.com,则可覆盖你的 SSH 设置来强制与 GitHub.com 的任何连接均通过该服务器和端口运行。
- 要在 SSH 配置文件中设置此行为,请在 ~/.ssh/config 编辑该文件,并添加以下部分:
Host github.com
Hostname ssh.github.com
Port 443
User git
- 您可以通过再次连接到 GitHub.com 测试此项是否有效:
$ ssh -T git@github.com
> Hi username! You've successfully authenticated, but GitHub does not
> provide shell access
最后再去使用git命令通过SSH方式链接就完全没问题了。