Search code examples
gitproxyhttp-proxyopensuse

git behind proxy with user name and password


In my development lab I have the following setup.

I have a proxy (with no password) through which I access the company code:

SO>cat ~/.ssh/config
Host my.company.net
    User git
    IPQoS throughput
    ProxyCommand nc -w 15 -X connect -x 10.26.192.28:3128 %h %p

#Host github.com
    #User git
    #ProxyCommand nc -w 5 -X connect -x 10.14.0.2:3128 %h %p


SO>

Initially we had a proxy with no password to access the Internet. The problem that I'm facing now is the fact that due to security concerns that proxy is now password protected and I can no longer use the same way to access the git repository from github/gitlab etc.

To put it in another words, the commented lines used to work, now they no longer do due to the proxy password.

Environment details are below:

SO>cat /etc/os-release | grep -i pretty
PRETTY_NAME="openSUSE Leap 15.5"
SO>rpm -qf `which nc`
netcat-openbsd-1.203-150400.1.5.x86_64
SO>git --version
git version 2.35.3
SO>

Thanks in advance for any proper suggestion - yes, I looked at some other similar questions but couldn't find any of them usable to my particular case.


Solution

  • ncat can work with authenticated proxy:

    ncat --proxy-type http --proxy 10.26.192.28:3128 --proxy-auth proxyuser:password
    

    Found in the docs at https://nmap.org/ncat/guide/ncat-proxy.html

    So try this in your ~/.ssh/config:

    Host my.company.net
        User git
        IPQoS throughput
        ProxyCommand ncat --proxy-type http --proxy 10.26.192.28:3128 --proxy-auth proxyuser:password %h %p