git github:没有可用的受支持的身份验证方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3431314/
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 08:52:08  来源:igfitidea点击:

github: No supported authentication methods available

gitsshgithubmsysgit

提问by Sonic Soul

i use github and have successfully added and synched files on my laptop in the past.

我使用 github 并且过去在我的笔记本电脑上成功添加和同步了文件。

as of recent i started getting "PuTTY Fatal Error: Disconnected: No supported authentication methods available" after running:

最近我开始在运行后收到“ PuTTY Fatal Error: Disconnected: No supported authentication methods available”:

git pull origin master (or push)

git pull origin master(或推)

however

然而

ssh [email protected] returns the correct response: ERROR: Hi username! You've successfully authenticated, but GitHub does not provide shell access Connection to github.com closed.

ssh [email protected] 返回正确的响应:错误:您好用户名!您已成功通过身份验证,但 GitHub 不提供 shell 访问连接到 github.com 已关闭。

after digging around on github i found this morcel:

在github上挖掘后,我发现了这个morcel:

No supported authentication methods availableYou should be aware of the environment variable GIT_SSH, which is used by git to find your ssh-speaking client, if ssh doesn't work for you. The git install may be using plink.exe (via GIT_SSH) to perform the authentication. If so, make sure you have pageant.exe running, and the key you created for github loaded into it. This provides the key to plink.exe; without it, the above error will occur.

没有可用的受支持的身份验证方法您应该注意环境变量 GIT_SSH,如果 ssh 对您不起作用,git 会使用它来查找使用 ssh 的客户端。git install 可能正在使用 plink.exe(通过 GIT_SSH)来执行身份验证。如果是这样,请确保您已运行 pageant.exe,并且您为 github 创建的密钥已加载到其中。这提供了 plink.exe 的密钥;没有它,就会出现上面的错误。

not sure what plink.exe or peagant.exe is.. and the fact that ssh [email protected] seems to authenticate correctly makes me wonder what the best solution here is.. i certainly don't want to overcomplicate my setup if not necessary.

不确定 plink.exe 或 peagant.exe 是什么......而且 ssh [email protected] 似乎正确验证的事实让我想知道这里最好的解决方案是什么......我当然不想让我的设置过于复杂,如果不是的话必要的。

回答by Rex Morgan

You can create a file named ".profile" in your home directory, for me that's C:\Users\[user]

你可以在你的主目录中创建一个名为“.profile”的文件,对我来说是 C:\Users\[user]

Inside that file, put the following line of code:

在该文件中,放入以下代码行:

GIT_SSH="/usr/bin/ssh.exe"

This will set the GIT_SSH environment variable to use the ssh client included with git.

这将设置 GIT_SSH 环境变量以使用 git 附带的 ssh 客户端。

The .profile script gets executed when you start your Git Bash command line.

.profile 脚本在您启动 Git Bash 命令行时执行。

Edit: This is my .profile. It will ask you for your password the first time you start the git command prompt, then will remember it from then on, until you reboot your computer. Very handy so you don't have to keep entering your password each time you want to do something.

编辑:这是我的 .profile。它会在您第一次启动 git 命令提示符时询问您的密码,然后会记住它,直到您重新启动计算机。非常方便,因此您不必每次想做某事时都输入密码。

SSH_ENV="$HOME/.ssh/environment"
GIT_SSH="/usr/bin/ssh.exe"

function start_agent {
echo "Initializing new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}

# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
#ps ${SSH_AGENT_PID} doesn't work under cygwin
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi

回答by Joseph Dykstra

Using TortoiseGit

使用 TortoiseGit

TortoiseGit > Settings ... Network ... SSH Client: C:\Program Files\Git\usr\bin\ssh.exe

TortoiseGit > 设置 ... 网络 ... SSH 客户端: C:\Program Files\Git\usr\bin\ssh.exe

Location my vary. On one computer it was in C:\Program Files (x86)\Git\bin\ssh.exe

位置各不相同。在一台计算机上它在C:\Program Files (x86)\Git\bin\ssh.exe

tortoisegit

乌龟

回答by woodvi

"... not sure what plink.exe or peagant.exe is ..."

“……不确定 plink.exe 或 peagant.exe 是什么……”

Since you ask: plink & pageant are part of the PuTTY suite, which is an implementation of SSH that supports Linux & Windows and is completely dominant on Windows.

既然你问:plink 和 pageant 是 PuTTY 套件的一部分,它是支持 Linux 和 Windows 的 SSH 实现,在 Windows 上完全占主导地位。

SSH

SSH

Secure Shell (SSH) is a cryptographic network protocol for securing data communication. It establishes a secure channel over an insecure network in a client-server architecture, connecting an SSH client application with an SSH server. Common applications include remote command-line login, remote command execution, but any network service can be secured with SSH.

Secure Shell (SSH) 是一种用于保护数据通信的加密网络协议。它在客户端-服务器架构中的不安全网络上建立安全通道,将 SSH 客户端应用程序与 SSH 服务器连接。常见应用包括远程命令行登录、远程命令执行,但任何网络服务都可以使用 SSH 进行保护。

if you ever used Telnet, it's like that (but more secure): it allows you to remotely access the bash shell (command line) of a Linux host.

如果您曾经使用过 Telnet,它就像那样(但更安全):它允许您远程访问 Linux 主机的 bash shell(命令行)。

PuTTY

油灰

PuTTY is a free and open-source terminal emulator, serial console and network file transfer application. It supports several network protocols, including SCP, SSH, Telnet, rlogin ...

PuTTY 是一个免费的开源终端模拟器、串行控制台和网络文件传输应用程序。它支持多种网络协议,包括 SCP、SSH、Telnet、rlogin...

On Windows it's the dominant software for remotely accessing a Linux host's command line under the SSH protocol (above). In Windows, .exe extensions are for executables. So those notes about plink.exe & pageant.exe probably don't apply if you're in Linux. PuTTY includes

在 Windows 上,它是在 SSH 协议下远程访问 Linux 主机命令行的主要软件(上图)。在 Windows 中,.exe 扩展名用于可执行文件。所以如果你在 Linux 中,那些关于 plink.exe 和 pageant.exe 的说明可能不适用。腻子包括

Plink: a command-line interface to the PuTTY back ends

Pageant: an SSH authentication agent for PuTTY, PSCP and Plink

Plink:PuTTY 后端的命令行界面

Pageant: PuTTY、PSCP 和 Plink 的 SSH 身份验证代理

From (http://en.wikipedia.org/wiki/Secure_Shell#Key_management)

来自(http://en.wikipedia.org/wiki/Secure_Shell#Key_management

When the public key is present on the remote end and the matching private key is present on the local end, typing in the password is no longer required ... for additional security the private key itself can be locked with a passphrase.

当远程端存在公钥并且本地端存在匹配的私钥时,不再需要输入密码......为了额外的安全性,可以使用密码锁定私钥本身。

So github is hosted on a Linux machine and uses SSH to secure the connection. SSH either authenticates with passwords or keys, many hosts (github?) only authenticate with keys. You setup is apparently trying to authenticate with a key. Keys and hosts are not one-for-one: you can have two keys for the same host and/or two hosts for the same key, so they need to be managed. If you are in Windows, then your SSH session is probably accessed through plink and your keys are probably managed by Pageant.

因此 github 托管在 Linux 机器上,并使用 SSH 来保护连接。SSH 使用密码或密钥进行身份验证,许多主机(github?)仅使用密钥进行身份验证。您的设置显然是在尝试使用密钥进行身份验证。密钥和主机不是一对一的:您可以为同一主机拥有两个密钥和/或为同一密钥拥有两个主机,因此需要对其进行管理。如果您使用的是 Windows,那么您的 SSH 会话可能是通过 plink 访问的,并且您的密钥可能由 Pageant 管理。

Import the key you need each time you load Pageant. If you followed guides that said "import your key", and saw that it worked, but it doesn't work now, see Chapter 9: Using Pageant for authentication.

每次加载 Pageant 时导入所需的密钥。如果您遵循了“导入您的密钥”的指南,并且看到它起作用,但现在不起作用,请参阅第 9 章:使用 Pageant 进行身份验证

One last tip if you are on Windows: you may have multiple instances of the PuTTY suite installed by various tools. TortoiseGit, for example, installs its own.

如果您使用的是 Windows,最后一个提示是:您可能有多个由各种工具安装的 PuTTY 套件实例。例如,TortoiseGit 安装自己的。

回答by vaughan

I experienced this problem because my GIT_SSHwas pointing to the TortoiseSVN version of Plink.exe. I changed it to point to the TortoiseGit version, restarted cmd and it worked.

我遇到了这个问题,因为我GIT_SSH指向的是 TortoiseSVN 版本的Plink.exe. 我将其更改为指向 TortoiseGit 版本,重新启动 cmd 并且它起作用了。

I can't remember exactly, but the TortoiseSVN version might have been 32-bit version, and the TortoiseGit version was 64-bit (located in Program Files, not Program Files (x86)).

我记不清了,但 TortoiseSVN 版本可能是 32 位版本,而 TortoiseGit 版本是 64 位(位于Program Files,而不是Program Files (x86))。

Double-check your GIT_SSHenv var.

仔细检查你的环境GIT_SSH变量。

I prefer to use git with normal cmd.exe(in Console2 of course)

我更喜欢在正常情况下使用 git cmd.exe(当然在 Console2 中)

回答by Simon East

For TortoiseGit Users on Windows

对于 Windows 上的 TortoiseGit 用户

Originally, I used to setup most of my Github/Bitbucket repositories using the SSH repository URLsas (originally) it used to be the only convenient way to prevent TortoiseGit from prompting for your password on every single action.

最初,我曾经使用SSH 存储库 URL来设置我的大部分 Github/Bitbucket 存储库,因为(最初)它曾经是防止 TortoiseGit 在每个操作中提示输入密码的唯一便捷方法。

But setting TortoiseGit up this way was always hair-pullingly painful. Every time it took me hoursto set up correctly, as the default installation options never seemed to work (even as of 2016, sheesh!).

但是以这种方式设置 TortoiseGit 总是令人毛骨悚然。每次我都需要花费数小时才能正确设置,因为默认安装选项似乎从未奏效(即使在 2016 年,天哪!)。

But TortoiseGit now has better password management for HTTPS, and Github actually recommends using HTTPS URLswherever possible.

但是 TortoiseGit 现在对 HTTPS 有更好的密码管理,而且Github 实际上建议尽可能使用 HTTPS URL

SSH URL: [email protected]:User/repo-name.git

HTTPS URL: https://github.com/User/repo-name.git

SSH 网址: [email protected]:User/repo-name.git

HTTPS 网址: https://github.com/User/repo-name.git

The benefits of HTTPS are:

HTTPS 的好处是:

  • No managing or generating of SSH keys
  • No need to have pageant.execonstantly running (which requests your password on each launch)
  • Using TortoiseGit from Australia, I find that clones over HTTPS are 5-10x faster than SSH
  • 无需管理或生成 SSH 密钥
  • 无需pageant.exe不断运行(每次启动时都会要求输入密码)
  • 使用来自澳大利亚的 TortoiseGit,我发现通过 HTTPS 的克隆比 SSH 快 5-10 倍

回答by Jon Schneider

If you're using Pageant and are getting the error described in the question after rebooting your PC (or otherwise closing and reopening Pageant):

如果您正在使用 Pageant 并且在重新启动 PC(或以其他方式关闭并重新打开 Pageant)后收到问题中描述的错误:

The error can be caused by Pageant not having your GitHub SSH key actively loaded.By default, Pageant does NOT automatically load the keys from the previous session when it starts up.

该错误可能是由于 Pageant 没有主动加载您的 GitHub SSH 密钥造成的。默认情况下,Pageant 在启动时不会自动加载上一个会话中的密钥。

To load the key:

加载密钥:

  1. Open Pageant. (On Windows, if Pageant is running, it'll have an icon in the system tray. Double-click that.)
  2. Click the Add Key button, and proceed to add your existing GitHub SSH key.
  1. 打开选美。(在 Windows 上,如果 Pageant 正在运行,它会在系统托盘中有一个图标。双击它。)
  2. 单击添加密钥按钮,然后继续添加您现有的 GitHub SSH 密钥。

To avoid this problem in the future, you can configure Pageant to automatically load your key when it starts up. (Pageant will automatically prompt you for a password if your key is password-protected.)

为避免将来出现此问题,您可以将 Pageant 配置为在启动时自动加载您的密钥。(如果您的密钥受密码保护,Pageant 将自动提示您输入密码。)

Steps to do this (assuming you already have Pageant configured to run when Windows starts):

执行此操作的步骤(假设您已将 Pageant 配置为在 Windows 启动时运行):

  1. Find the shortcut used by Windows to run Pageant when Windows starts. (It may be in the Startup folder, which can be opened by Start > Run > shell:startup)
  2. In the shortcut's Properties dialog, append the full path and filename of the SSH key file to the "Target" field.
  1. 查找 Windows 启动时用于运行 Pageant 的快捷方式。(它可能在Startup文件夹中,可以通过开始>运行>打开shell:startup
  2. 在快捷方式的“属性”对话框中,将 SSH 密钥文件的完整路径和文件名附加到“目标”字段。

Reference and full details: http://blog.shvetsov.com/2010/03/making-pageant-automatically-load-keys.html

参考和完整细节:http: //blog.shvetsov.com/2010/03/making-pageant-automatically-load-keys.html

回答by BlueRaja - Danny Pflughoeft

My issue was that I was attempting to use my github username. Apparently when using Github (or is it a Git thing?), if you use key-based authentication, you need to set your username to git.

我的问题是我试图使用我的 github 用户名。显然,在使用 Github (或者它是 Git 的东西?)时,如果您使用基于密钥的身份验证,则需要将您的用户名设置为git.

I'm not sure why you even need a username at all - perhaps someone more knowledgeable can explain that?

我不知道为什么你甚至需要一个用户名 - 也许更有知识的人可以解释一下?

回答by atorres757

On my Windows 7 machine running Github for Windows using git version 1.8.3.msysgit.0. I found that updating my system environment variable GIT_SSH to C:\Program Files (x86)\Git\bin\ssh.exe seemed to do the trick. This also fixed my issue with contacting OpenShift's git repo.

在我运行 Github for Windows 的 Windows 7 机器上,使用 git 版本 1.8.3.msysgit.0。我发现将系统环境变量 GIT_SSH 更新为 C:\Program Files (x86)\Git\bin\ssh.exe 似乎可以解决问题。这也解决了我联系 OpenShift 的 git repo 的问题。

回答by Dmitriy

Worked for me on Windows 8: GIT_SSH variable was pointing to plink.exe, Changed it in the system settings to point to the ssh binary, and that has fixed the problem. To find out full path to the ssh, run:

在 Windows 8 上对我来说有效:GIT_SSH 变量指向 plink.exe,在系统设置中将其更改为指向 ssh 二进制文件,并解决了问题。要找出 ssh 的完整路径,请运行:

where ssh

回答by Lismore

To resolve this issue this was what I did.

为了解决这个问题,这就是我所做的。

I was using Git Bash on Windows 10

我在 Windows 10 上使用 Git Bash

I started Pageant, pressed Add Key,

我开始选美,按添加键,

enter image description here

在此处输入图片说明

navigated to C:\Users\username\.ssh folder and chose my key

导航到 C:\Users\username\.ssh 文件夹并选择我的密钥

enter image description here

在此处输入图片说明

I then attempt to do a git push and it worked this time.

然后我尝试执行 git push 并且这次成功了。