egit - not authorized

六月ゝ 毕业季﹏ 提交于 2019-12-17 15:23:04

问题


I just connected to GIT from Eclipse Juno using EGit, and successfully cloned a certain remote repository. During the clone I entered my Github username and password, but chose not to save them.

Then I tried to "Fetch from Upstream". I got this error:

https://github.com/biunlp/nlp-lab.git: not authorized

I had no chance of entering my username and password...

This is strange since I connected to this repository in order to clone...


回答1:


A. To specify credentials individually for each remote

  1. Open Git repositories view,
  2. open "Remotes > origin > <your push url>"
  3. 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.

  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.




回答2:


You can try:

eclipse/myeclipse > menu

window > preferences > general > security >

content > click "delete" > ok




回答3:


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.

  1. Go to your GitHub.com settings, and in the left hand pane click Personal access tokens.
  2. Click Generate new token. Select the scopes that you'd like this token to be able to use, and generate it.
  3. Copy the token. It should look something like this: 9731f5cf519e9abb53e6ba9f5134075438944888 (don't worry, this is invalid).
  4. Back in Eclipse (Juno, since that's OP's version), click Window > Show View > Other.... Under Git, select Git Repositories.
  5. A new pane appears, from which you can open (repository name) > Remotes > origin.
  6. Right click on a node and choose Change Credentials.... Enter your username for User, and your secure access token for the Password.



回答4:


I had a similar problem when I changed my password on the remote repository.

Here is how I fixed it on Eclipse on Mac:

Important Note: These instructions have the side effect of clearing all passwords and other secure information. I was fine with that, but you will want to consider that before you follow these instructions.

  1. Click Eclipse -> Preferences on menu.
  2. Expect a popup window called Preferences.
  3. Expand the "General" tree item.
  4. Double click the "Security" tree item.
  5. Expect the main pane of the popup to change to "See 'Secure Storage' for..."
  6. Click 'Secure Storage'.
  7. Expect the main pane to change to tabbed window.
  8. Click the "Contents" tab.
  9. Click "Delete".
  10. Accept a warning that all your secure information is deleted.
  11. Click "Cancel" or "Apply" to exit the popup window.
  12. Click the 'Git Pull' icon and expect to be prompted for username and password.


来源:https://stackoverflow.com/questions/14259265/egit-not-authorized

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!