Add this to your ssh config file ( which is located in %USERPROFILE%\.ssh\config
) or create one if it's missing:
Host *
ProxyCommand "C:/Program Files/Git/mingw64/bin/connect.exe" -H {proxyserver}:{port} %h %p
or (for specific host name)
Host gitlab.com
ProxyCommand "C:/Program Files/Git/mingw64/bin/connect.exe" -H {proxyserver}:{port} %h %p
Host *
ProxyCommand "C:/Program Files/Git/mingw64/bin/connect.exe" -S {proxyserver}:{port} %h %p
or (for specific host name)
Host gitlab.com
ProxyCommand "C:/Program Files/Git/mingw64/bin/connect.exe" -S {proxyserver}:{port} %h %p
install connect
:
sudo apt install connect-proxy
then update ssh config file ( which is located in ~/.ssh/config
) or create one if it's missing :
Host *
ProxyCommand connect -H {proxyserver}:{port} %h %p
or (for specific host name)
Host gitlab.com
ProxyCommand connect -H {proxyserver}:{port} %h %p
Host *
ProxyCommand connect -S {proxyserver}:{port} %h %p
or (for specific host name)
Host gitlab.com
ProxyCommand connect -S {proxyserver}:{port} %h %p
install proxychains
:
sudo apt install proxychains-ng
create proxychains config in :
~/.proxychains/proxychains.conf
config file content (for http proxy & repo access via http/ssh):
strict_chain
proxy_dns
tcp_read_time_out 150000
tcp_connect_time_out 80000
[ProxyList]
http {proxyserver} {port}
config file content (for socks proxy & repo access via http/ssh):
strict_chain
proxy_dns
tcp_read_time_out 150000
tcp_connect_time_out 80000
[ProxyList]
socks5 {proxyserver} {port}
use proxychains to encapsulate git:
alias gitproxy='proxychains git'
gitproxy clone path/to/repo.git
or
proxychains git clone path/to/repo.git
install socat
:
sudo apt install socat
then update ssh config file ( which is located in ~/.ssh/config
) or create one if it's missing :
Host *
ProxyCommand socat - PROXY:{proxyserver}:%h:%p,proxyport={port}
or (for specific host name)
Host gitlab.com
ProxyCommand socat - PROXY:{proxyserver}:%h:%p,proxyport={port}
If you want to use git inside wsl2 through proxy, GNU/Linux (Debian/Ubuntu) method works here too without any issue.
But, in my case, proxy server is running on my windows (out of wsl distro) and the problem is that localhost
address inside wsl is not pointing to windows host. plus windows host ip address inside wsl can change dynamically with each startup.
To fix this you need to read windows ip address from resolv.conf
and here is the complete command with connect
method ✨:
Host *
ProxyCommand connect -H `grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'`:{port} %h %p
Host *
ProxyCommand connect -S `grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'`:{port} %h %p
Use git cli:
git config --global http.proxy http://{proxyserver}:{port}
or (for specific host name)
git config --global http.https://gitlab.com.proxy http://{proxyserver}:{port}
Don't forget to replace {proxyserver}
& {port}
with your proxy address. e.g {proxyserver}:{port}
=> 127.0.0.1:1080