通过SSH连接远程仓库

报错:ssh: connect to host github.com port 22: Connection timed out

解决
according to:this gist

ssh访问

需要修改~/.ssh/config文件, 没有的话新建一个. 同样仅为github.com设置代理:(在linux or macos下)

1
2
3
Host github.com
User git
ProxyCommand nc -v -x 127.0.0.1:10808 %h %p

但是win没有nc命令,所以

如果是在Windows下, 则需要修改用户目录下.ssh\config, 其中内容类似于:

1
2
3
Host github.com
User git
ProxyCommand connect -S 127.0.0.1:10808 %h %p

这里-S表示使用socks5代理, 如果是http代理则为-H. connect工具git自带, 在\mingw64\bin\下面.

如我本人使用http代理,则配置

1
ProxyCommand connect -H 127.0.0.1:10809 %h %p

注意对应端口为http端口

SSH原理

博客链接


通过SSH连接远程仓库
http://blog.1314171.xyz/post/220511ssh-connect-to-ssh-github.html
作者
TT2TER
发布于
2022年5月11日
许可协议