egit - not authorized
A. To specify credentials individually for each remote
- Open Git repositories view,
- open "
Remotes > origin > <your push url>
" - click "Change Credentials..."
(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.
- Create a text file called
.netrc
(_netrc
in Windows) in the user home directory. - 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.
If you're using Two Factor Authentication on GitHub, the "not authorized" error can be returned even if you are using the correct username and password. This can be resolved by generating a personal access token.
After generating the secure access token, we'll use this instead of a password. Make sure not to leave the page before you're done, because once you leave the page, you'll never see it again (thankfully it can be regenerated, but anything using the previously generated token will cease to authenticate).
This assumes that you've successfully installed EGit and that you've successfully cloned a repository.
- Go to your GitHub.com settings, and in the left hand pane click
Personal access tokens
. - Click
Generate new token
. Select the scopes that you'd like this token to be able to use, and generate it. - Copy the token. It should look something like this:
9731f5cf519e9abb53e6ba9f5134075438944888
(don't worry, this is invalid). - Back in Eclipse (Juno, since that's OP's version), click
Window > Show View > Other...
. UnderGit
, selectGit Repositories
. - A new pane appears, from which you can open
(repository name) > Remotes > origin
. - Right click on a node and choose
Change Credentials...
. Enter your username forUser
, and your secure access token for thePassword
.