Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Git on Windows, behind an HTTP proxy, without storing proxy password on disk

I'm using Git on Windows, on a corporate network where I'm behind an HTTP proxy with Basic authentication. Outbound SSH doesn't work, so I have to use HTTPS through the proxy.

I'm aware of how to use git config http.proxy to configure the settings as http://[username]:[password]@[proxy]:[port].

However, particularly as this is a shared machine, I'd rather not store my password in my .gitconfig. Additionally, changing my .gitconfig using the git config command leaves my password in my bash history, so even if I remember to clear my .gitconfig at the end of the session, I'll almost certainly forget to clear my history as well.

I've tried setting http.proxy without a password, in the vain hope that I'd get a prompt asking me for my password when I try to push/pull, but I only get a 407 Proxy Authentication Required. All the information I've found online seems to either ignore the issues with having the password saved in plaintext in .gitconfig, or deals with NTLM proxies.

I'm quite happy to type my proxy details every time I need to connect - the best solution I can see at the moment is writing a wrapper script that will prompt for my password and set that as an environment variable when calling git proper. Is this a decent solution, and are there any security implications to setting an environment variable for a single call in a script? Preferably, are there any built-in settings or existing tools that I can use for this?

like image 604
ajd Avatar asked Apr 02 '14 01:04

ajd


People also ask

How do I git behind a proxy?

Setting the proxy for Git Run the following commands replacing USERNAME , PASSWORD , PROXY_ADDRESS , and PROXY_PORT with your network's information: git config --global --add http. proxy http://USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT. git config --global --add https.

Does GIT use Http_proxy?

Now whenever you do anything with [email protected] , it will use the proxy automatically.

How do I set HTTP proxy on Windows?

Select the Start button, then select Settings > Network & Internet > Proxy. Under Manual proxy setup, turn on Use a proxy server. Do the following: In the Address and Port boxes, enter the proxy server name or IP address and port (optional) in the respective boxes.

Does PowerShell use WinHTTP proxy?

Set WinHTTP Proxy Server Settings for PowerShellYou can centrally configure Winnhttp proxy settings on domain computers using a GPO. If the command returns False , the connection to this URL will be made through the proxy configured in your PowerShell session.


1 Answers

since git 2.8.0

git config --global http.proxy http://[user]@proxyhost:port git config --global credential.helper wincred 
like image 199
0xA0 Avatar answered Oct 09 '22 19:10

0xA0