egit – not authorized

Update 2022: In what follows, always use:

  • a App password, not your account password (see blog post).
    So create your app password.
  • a BitBucket Cloud, since BitBucket server will be discontinued in Feb. 2024.

A. To specify credentials individually for each remote

  1. Open Git repositories view,
  2. open “Remotes > origin > <your push url>
  3. click “Change Credentials…”

push menu

(From User Guide – Resource Context Menu)

B. To specify credentials per server

If you want to access multiple repositories on the same server without providing the same credentials multiple times, you may use .netrc. With this, eGit will use the configuration you provide.

  1. Create a text file called .netrc (_netrc in Windows) in the user home directory.
  2. Add content to the file in this form:
    machine my.server1.com
    login yourUserName
    password yourPassword

    machine my.server2.com
    login yourUserName
    password yourPassword

The Stash documentation contains more information about .netrc

Security issue The problem with using .netrc this way is that the password is visible in plain text. Refer to this answer in Stackoverflow to solve that problem.


More secure option (2022): EGit (from issue 441198) can be made (with an extension) to recognize a native Git credential helper, using a secure encrypted cache:

  • install a native Git

  • install the GCM (Git Credential Manager), which is cross-platform, and already package with Git For Windows for instance.

  • instruct EGit to look for credentials in the GCM: gitflow-incremental-builder/gitflow-incremental-builder

  • register your password or token in said GCM

    printf "Host=my.server1.com\nprotocol=https\nusername=yourUsername1\npassword=passwd1" | \
    git credential-manager-core store  
    # and:  
    printf "Host=my.server1.com\nprotocol=https\nusername=yourUsername1\npassword=passwd1" | \
    git credential-manager-core store
    

Look for executable git-credential-manager-core, and add its folder to your %PATH%/$PATH.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)