git github,sourcetree 收到未经授权的错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23039133/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:00:13  来源:igfitidea点击:

github, sourcetree getting unauthorized error

gitatlassian-sourcetree

提问by Oscar Reyes

im new to github and im using sourcetree for my git gui, ive been using it for a few days, but now lately im getting an error that says

我是 github 的新手,我在我的 git gui 中使用 sourcetree,我已经使用它几天了,但最近我收到一个错误消息

remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/Nosthertus/nodejs_Chat.git/'

also when i tried to make another registration to github returns with error

也当我尝试再次注册到 github 时返回错误

authorization failed

maybe its because i made a two-factor security, i thought on making a shh-key with github, but does not fix the problem, there has to be a way to make my gui connect to my github account without the login access, how do i fix this?

也许是因为我做了一个双因素安全性,我想用 github 制作一个 shh-key,但没有解决问题,必须有一种方法让我的 gui 连接到我的 github 帐户而无需登录访问,如何我要解决这个问题吗?

采纳答案by VonC

its because i made a two-factor security

这是因为我做了一个两因素安全

Following the Heartbleed bug, GitHub has reset all browser sessions that were active prior to the vulnerability being addressed on our servers.

Heartbleed 漏洞之后,GitHub 重置了在我们的服务器上解决漏洞之前处于活动状态的所有浏览器会话。

Check if your PAT (Personnal Access token) is still valid in the Applications section of your GitHub Account.

检查您的 PAT(个人访问令牌)在您的 GitHub 帐户应用程序部分是否仍然有效。

Note that ssh keys have no effect on an https url like https://github.com/Nosthertus/nodejs_Chat.git

请注意,ssh 密钥对 https url 没有影响,例如https://github.com/Nosthertus/nodejs_Chat.git

Would you need to use your ssh key, you should at least change the origin url:

您是否需要使用 ssh 密钥,您至少应该更改原始 url:

git remote set-url origin [email protected]:Nosthertus/nodejs_Chat.git

回答by ntg

If your password recently changed, select the repository, go to Tools --> options, go to Authentication tab and delete the stored password. This will make the system request a new password when you next try to connect.

如果您最近更改了密码,请选择存储库,转至工具 --> 选项,转至身份验证选项卡并删除存储的密码。这将使系统在您下次尝试连接时请求新密码。

On OSX: go to SourceTree --> Preferences --> Network and delete the default username there.

在 OSX 上:转到 SourceTree --> Preferences --> Network 并删除那里的默认用户名。

回答by Yuval

I'm using Personal access tokens (GitHub -> settings -> Personal access tokens) and I needed to regenerate the token and then remove the username from SourceTree (SourceTree -> preferences -> network ->remove) then pull and you will be prompt to enter user name and password Use the token you generated

我正在使用个人访问令牌(GitHub -> 设置 -> 个人访问令牌),我需要重新生成令牌,然后从 SourceTree(SourceTree -> 首选项 -> 网络 -> 删除)中删除用户名,然后拉你提示输入用户名和密码 使用您生成的令牌

回答by Ferie

To work with GitHub's two-factor authentication in SourceTree you can simply use your access token instead of your password. The steps to do this are as follows:

要在 SourceTree 中使用 GitHub 的双因素身份验证,您只需使用访问令牌而不是密码即可。执行此操作的步骤如下:

  1. Go to your Personal Access Tokenssettings in GitHub.
  2. Click on the Generate new tokenbutton.
  3. Name the token something descriptive.
  4. Select which scopes you wish to grant this token.
  5. Click the Generate tokenbutton.
  6. Copy the token and use it as a passwordin your hosted repositories.
  1. 转到GitHub 中的个人访问令牌设置。
  2. 单击生成新令牌按钮。
  3. 将令牌命名为描述性的名称。
  4. 选择您希望授予此令牌的范围。
  5. 单击生成令牌按钮。
  6. 复制令牌并将其用作托管存储库中的密码

Source

来源

回答by Rick Putnam

I am using 2FA and I was able to resolve authentication issues by creating an API key as described in the linked document:

我正在使用 2FA,并且能够通过创建链接文档中所述的 API 密钥来解决身份验证问题:

https://confluence.atlassian.com/sourcetreekb/two-factor-authentication-2fa-with-github-in-sourcetree-402033499.html

https://confluence.atlassian.com/sourcetreekb/two-factor-authentication-2fa-with-github-in-sourcetree-402033499.html

Note: after generating the key, copy it and replace your password with the API key in SourceTree (Tools/Options/Authentication tab --> select item in Saved Passwords and click edit...)

注意:生成密钥后,将其复制并用 SourceTree 中的 API 密钥替换您的密码(工具/选项/身份验证选项卡 --> 在保存的密码中选择项目,然后单击编辑...)

I hope this helps.

我希望这有帮助。

回答by Swarit Agarwal

SOURCE TREE

源树

Tools > Options > Authentication > Edit (Edit Password)

工具 > 选项 > 身份验证 > 编辑(编辑密码)

回答by bcr

In addition to setting up the Personal Access Token as Ferie states above, this may be helpful (it's how I finally got it working)

除了像上面 Ferie 所说的那样设置个人访问令牌之外,这可能会有所帮助(这就是我最终让它工作的方式)

  • I made sure had the latest version of Sourcetree
  • I upgraded to the latest version of and used System Git (Tools -> Options -> Git)
  • Upgraded to the latest Git Credential Manager for Windows (this was via an installer I downloaded and double-clicked, very easy)
  • Ensured I was using OAuth for my GitHub account stored in Tools -> Options -> Authentication
  • Made sure I checked off the box "Allow Sourcetree to manage my credentials using the Git Credential Manager" (this was important!!) on Tools -> Options -> Git
  • Then when I triggered the GitHub dialog (via pushing a new branch, just an example), I logged in there (this is where it used to fail).
  • I next got the 2 factor auth dialog, and the code was sent to my phone as expected. I was able to enter the code from my phone into this dialog.
  • 我确定有最新版本的 Sourcetree
  • 我升级到最新版本并使用了 System Git(工具 -> 选项 -> Git)
  • 升级到适用于 Windows 的最新 Git Credential Manager(这是通过我下载并双击的安装程序,非常简单)
  • 确保我对存储在工具 -> 选项 -> 身份验证中的 GitHub 帐户使用 OAuth
  • 确保我在工具 -> 选项 -> Git 上勾选了“允许 Sourcetree 使用 Git 凭据管理器管理我的凭据”框(这很重要!!)
  • 然后当我触发 GitHub 对话框时(通过推送一个新分支,只是一个例子),我登录那里(这是它曾经失败的地方)。
  • 我接下来得到了 2 因素身份验证对话框,代码按预期发送到我的手机。我能够将手机中的代码输入到此对话框中。

回答by Mauro Bilotti

Make sure that your credentials are OK (please check before in the GitHub website), then, in my case the answer was the following.

确保您的凭据没问题(请在 GitHub 网站之前检查),然后,就我而言,答案如下。

1) Delete the "psswd" file without opening Sourcetree:

1)删除“psswd”文件而不打开Sourcetree:

C:\Users\USER\AppData\Local\Atlassian\SourceTree\passwd

C:\Users\USER\AppData\Local\Atlassian\SourceTree\passwd

2) After doing that, try to re-enter the application and specify your credentials again.

2) 执行此操作后,尝试重新输入应用程序并再次指定您的凭据。

3) If the previous steps doesn't work, in my case, it was using an incorrect username, so you can edit the "userhosts" file located in the same folder and change to the proper username that you're using:

3)如果前面的步骤不起作用,在我的情况下,它使用了不正确的用户名,因此您可以编辑位于同一文件夹中的“userhosts”文件并更改为您正在使用的正确用户名:

C:\Users\USER\AppData\Local\Atlassian\SourceTree\userhosts

C:\Users\USER\AppData\Local\Atlassian\SourceTree\userhosts

By doing this, I was able to push again. Hope it helps!

通过这样做,我能够再次推动。希望能帮助到你!