git config --global https.proxy http://127.0.0.1:1080 | |
git config --global https.proxy https://127.0.0.1:1080 | |
git config --global --unset http.proxy | |
git config --global --unset https.proxy | |
npm config delete proxy |
这是什么原理
结合以上各位经验设置成功. 以下以macOS为准.
https访问
仅为github.com设置socks5代理(推荐这种方式, 公司内网就不用设代理了, 多此一举):
git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
其中1086是socks5的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1086.
设置完成后, ~/.gitconfig文件中会增加以下条目:[http "https://github.com"] proxy = socks5://127.0.0.1:1086
ssh访问
需要修改~/.ssh/config文件, 没有的话新建一个. 同样仅为github.com设置代理:Host github.com User git ProxyCommand nc -v -x 127.0.0.1:1086 %h %p
如果是在Windows下, 则需要个性%home%.ssh\config, 其中内容类似于:
Host github.com User git ProxyCommand connect -S 127.0.0.1:1086 %h %p
这里-S表示使用socks5代理, 如果是http代理则为-H. connect工具git自带, 在\mingw64\bin\下面.
worked.
亲测可以,我的代理是Clash,端口改成默认的7890.
记录下问题过程: Clash 一开始使用Git命令没问题,突然某天提示:
ssh: connect to host ssh.github.com port 22: Connection refused
fatal: Could not read from remote repository.
win10配置:.ssh/config 配置文件供参考:
Host github.com
User git
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 22
ProxyCommand connect -S 127.0.0.1:7890 %h %p
win10配置成功,如下,感谢各位的指导!
Host github.com
HostName github.com
User git
ProxyCommand connect -S 127.0.0.1:33211 %h %p
带认证的http proxy咋配置呢
谢谢!
git config --global https.proxy 'https://127.0.0.1:1086'
↓↓
git config --global https.proxy https://[your_proxy_ip]:[your_proxy_port]
配置了.ssh/config,还是不行,我怀疑和我的机场有关系,之前用的都是可以的,现在换了两个了还是不行,无语了都,太难了。
分享一个windows下可行的ssh配置
Host github.com
User git
# http proxy
ProxyCommand ncat --proxy 127.0.0.1:10809 %h %p
最新的git不能加单引号,比如v2rayNG可以这么配置 git config --global http.proxy socks5://127.0.0.1:10808
👍🏻
一直在使用,最近不太稳定
结合以上各位经验设置成功. 以下以macOS为准.
https访问
仅为github.com设置socks5代理(推荐这种方式, 公司内网就不用设代理了, 多此一举):
git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
其中1086是socks5的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1086.
设置完成后, ~/.gitconfig文件中会增加以下条目:[http "https://github.com"] proxy = socks5://127.0.0.1:1086
ssh访问
需要修改~/.ssh/config文件, 没有的话新建一个. 同样仅为github.com设置代理:Host github.com User git ProxyCommand nc -v -x 127.0.0.1:1086 %h %p
如果是在Windows下, 则需要个性%home%.ssh\config, 其中内容类似于:
Host github.com User git ProxyCommand connect -S 127.0.0.1:1086 %h %p
这里-S表示使用socks5代理, 如果是http代理则为-H. connect工具git自带, 在\mingw64\bin\下面.
worked.
亲测可以,我的代理是Clash,端口改成默认的7890.
记录下问题过程: Clash 一开始使用Git命令没问题,突然某天提示:
ssh: connect to host ssh.github.com port 22: Connection refused fatal: Could not read from remote repository.
win10配置:.ssh/config 配置文件供参考:
Host github.com User git Hostname ssh.github.com PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa Port 22 ProxyCommand connect -S 127.0.0.1:7890 %h %p
亲测可以,困扰一天了~感谢
Mac ssh 设置还是很慢 5kb/s
如果你是在Linux下配置,那么应该为
ncat和netcat有些参数上的区别,见https://unix.stackexchange.com/questions/368155/what-are-the-differences-between-ncat-nc-and-netcat