Permanent authentication for Git repositories over HTTP(S)

Currently, Fisheye only supports HTTP or HTTPS for pushing and pulling from Git repositories. Git has no method of caching the user's credentials, so you need to re-enter them each time you perform a clone, push or pull.

Fortunately, there is a mechanism that allows you to specify which credentials to use for which server: the .netrc file.

Warning!

Git uses a utility called cURL under the covers, which respects the use of the .netrc file. Be aware that other applications that use curl to make requests to servers defined in your .netrc file will also now be authenticated using these credentials. Also, this method of authentication is potentially unsuitable if you are accessing your Fisheye server via a proxy, as all curl requests that target a path on that proxy server will be authenticated using your .netrc credentials.

Warning!

cURL will not match the machine name in your .netrc if it has a username in it, so make sure you edit your .git/config file in the root of your clone of the repository and remove the user and '@' part from any clone url's (url fields) that look like https://user@machine.domain.com/... so instead they look like http://machine.domain.com/...

Linux or OSX
  1. Create a file called .netrc in your home directory (~/.netrc). Unfortunately, the syntax requires you to store your passwords in plain text - so make sure you modify the file permissions to make it readable only to you.
  2. Add credentials to the file for the server or servers you want to store credentials for, using the format below. You may use either IP addresses or hostnames, and you do not need to specify a port number, even if you're running Fisheye on a non-standard port.

    machine fisheye1.mycompany.com
    login myusername 
    password mypassword
    machine fisheye2.mycompany.com
    login myotherusername
    password myotherpassword   
  3. And that's it! Subsequent git clone, git pull and git push requests will be authenticated using the credentials specified in this file.
Windows
  1. Create a text file called _netrc in your home directory (e.g. c:\users\kannonboy\_netrc). Curl has problems resolving your home directory if it contains spaces in its path (e.g. c:\Documents and Settings\kannonboy). However, you can update your %HOME% environment variable to point to any old directory, so create your _netrc in a directory with no spaces in it (for example c:\curl-auth\) then set your %HOME% environment variable to point to the newly created directory.
  2. Add credentials to the file for the server or servers you want to store credentials for, using the format from the Linux or OSX section above.
Last modified on Oct 25, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.