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

发布于 2024-09-13 04:00:36 字数 875 浏览 7 评论 0原文

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

截至最近,我在运行后开始收到“PuTTY 致命错误:已断开连接:没有可用的受支持的身份验证方法”:

git pull origin master (或推送)

但是

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

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

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

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

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

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

git pull origin master (or push)

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.

after digging around on github i found this morcel:

No supported authentication methods available
You 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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(18

怂人 2024-09-20 04:00:36

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

在该文件内,输入以下代码行:

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

这将设置 GIT_SSH 环境变量以使用包含的 ssh 客户端与 git 一起。

当您启动 Git Bash 命令行时,.profile 脚本就会被执行。

编辑:
这是我的.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

You can create a file named ".profile" in your home directory, for me that's 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.

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

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.

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
╄→承喏 2024-09-20 04:00:36

使用 TortoiseGit

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

位置可能有所不同。在一台计算机上,它位于 C:\Program Files (x86)\Git\bin\ssh.exe

“乌龟吉特”

Using TortoiseGit

TortoiseGit > Settings ... Network ... SSH Client: 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

tortoisegit

八巷 2024-09-20 04:00:36

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

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

SSH

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

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

PuTTY

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

在 Windows 上,它是在 SSH 协议下远程访问 Linux 主机命令行的主要软件(见上图)。在 Windows 中,.exe 扩展名用于可执行文件。所以关于 plink.exe 和 plink.exe 的注释pageant.exe 可能如果您使用的是 Linux,则不适用。 PuTTY 包括

Plink:PuTTY 后端的命令行界面

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

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

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

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

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

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

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

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.

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.

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.

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 ...

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

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

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

From (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.

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.

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.

遮云壑 2024-09-20 04:00:36

我遇到此问题是因为我的 GIT_SSH 指向 Plink.exe 的 TortoiseSVN 版本。我将其更改为指向 TortoiseGit 版本,重新启动 cmd,它就工作了。

我记不太清了,但 TortoiseSVN 版本可能是 32 位版本,而 TortoiseGit 版本是 64 位(位于 Program Files 中,而不是 Program Files (x86)< /代码>)。

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

我更喜欢将 git 与普通的 cmd.exe 一起使用(当然在 Console2 中)

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

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)).

Double-check your GIT_SSH env var.

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

温柔嚣张 2024-09-20 04:00:36

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

该错误可能是由于 Pageant 未主动加载 GitHub SSH 密钥而导致的。 默认情况下,Pageant 在启动时不会自动加载上一个会话的密钥。

加载密钥:

  1. 打开 Pageant。 (在 Windows 上,如果 Pageant 正在运行,它将在系统托盘中显示一个图标。双击该图标。)
  2. 单击“添加密钥”按钮,然后继续添加现有的 GitHub SSH 密钥。

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

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

  1. 找到 Windows 在 Windows 启动时运行 Pageant 所使用的快捷方式。 (它可能位于 Startup 文件夹中,可以通过“开始”>“运行”> shell:startup 打开该文件夹)
  2. 在快捷方式的“属性”对话框中,将 SSH 密钥文件的完整路径和文件名附加到“目标”字段。

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

If you're using Pageant and are getting the error described in the question after rebooting your PC (or otherwise closing and reopening 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.

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.

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.)

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

  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.

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

温柔女人霸气范 2024-09-20 04:00:36

对于 Windows 上的 TortoiseGit 用户

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

但以这种方式设置 TortoiseGit 总是让人头疼。每次我都要花费几个小时才能正确设置,因为默认安装选项似乎从来都不起作用(即使到了 2016 年,天哪!)。

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

SSH URL:[电子邮件受保护]:用户/仓库名称.git

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

HTTPS 的好处是:

  • 无需管理或生成 SSH 密钥
  • 无需 pageant.exe 不断运行(每次启动时都会请求您的密码)
  • 使用澳大利亚的 TortoiseGit,我发现通过 HTTPS 的克隆比 SSH 快 5-10 倍

For TortoiseGit Users on Windows

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

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

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

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

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

The benefits of HTTPS are:

  • No managing or generating of SSH keys
  • No need to have pageant.exe constantly running (which requests your password on each launch)
  • Using TortoiseGit from Australia, I find that clones over HTTPS are 5-10x faster than SSH
给妤﹃绝世温柔 2024-09-20 04:00:36

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

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

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.

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

凡尘雨 2024-09-20 04:00:36

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

where ssh

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:

where ssh
撩起发的微风 2024-09-20 04:00:36

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

我在 Windows 10 上使用 Git Bash

我启动了 Pageant,按下添加键,

在此处输入图像描述

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

在此处输入图像描述

然后我尝试进行 git Push,这次成功了。

To resolve this issue this was what I did.

I was using Git Bash on Windows 10

I started Pageant, pressed Add Key,

enter image description here

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

enter image description here

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

残花月 2024-09-20 04:00:36

我刚刚通过将 GIT_SSH env var 设置为 ssh 解决了完全相同的问题。就这3个字母。

我强烈建议 Windows 10 用户将 GIT_SSH 设置为 ssh 字符串(无扩展名)以外的任何内容,以最大限度地提高 Windows 终端之间的交叉操作性, git bash、cmd,甚至 PHP Storm。显然,您的 %PATH% 必须有 ssh.exe

我建议您安装适用于 Windows 的 Git,并在 %PATH% 下添加 C:\Program Files\Git\usr\bin

如果您重新安装了适用于 Windows 的 Git,请准备再次设置它,安装程序将要求您指定“plink”。它几乎不知道“ssh”会起作用。该安装程序无论如何都会拒绝除绝对路径之外的任何其他内容。

我敢提醒您,在更改 GIT_SSH 值和/或路径后,您显然应该重新启动控制台或 IDE。

这个答案涉及解决这个问题:
"不能在连接到 Github 时生成 ssh”,但 ssh -T [email protected] 有效吗?

I just solved the exact same issue by setting GIT_SSH env var to ssh. Just these 3 letters.

I strongly discourage Windows 10 users to set GIT_SSH to anything else than just ssh string (no extension), to maximise cross operability between Windows Terminal, git bash, cmd, and even PHP Storm. Obviously, your %PATH% will have to have ssh.exe in its way.

I recommend you install Git for Windows, and you add C:\Program Files\Git\usr\bin down your %PATH%

If you ever reinstall Git for Windows, be ready to set it again, and the install will ask you to specify a "plink". Little does it know that "ssh" will work to. That installer will anyway refuse anything else than an absolute path.

May I dare reminding that you obivously should restart your console or IDE after changing GIT_SSH value and/or your path.

This answer relates to solving this issue:
"Cannot spawn ssh" when connecting to Github, but ssh -T [email protected] works?

请爱~陌生人 2024-09-20 04:00:36

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

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.

流绪微梦 2024-09-20 04:00:36

在将 GitExtensions 更新到版本 3.3.0.7719 后,我遇到了类似的问题。

不知何故,它恢复了我的身份验证设置以使用 PuTTY 而不是 OpenSSH。

在该版本中,这里是我用来再次启用 OpenSSH 的菜单:

在此处输入图像描述

I had a similar issue after updating GitExtensions to version 3.3.0.7719

Somehow it reverted my authentication settings to use PuTTY instead of OpenSSH.

In that version here is the menu I used to enable OpenSSH again:

enter image description here

热血少△年 2024-09-20 04:00:36

相同的错误,此处指出不同的解决方案 - 连接问题Windows 上的 GitHub,甚至通过 PuTTY

Same error, different solution noted here - Problem connecting to GitHub on Windows, even via PuTTY

臻嫒无言 2024-09-20 04:00:36

我遇到了同样的问题,但是 GIT_SSH 解决方案似乎对我有用一次。计算机重新启动后,我意识到这是另一回事,因为我能够使用 Git Bash 或命令提示符毫无问题地克隆我的私人存储库,但在使用 SublimeGit 插件的 Sublime Text 3 中却不能。我的解决方案很简单,实际上就是 @BlueRaja - Danny Pflughoeft 提到的,但我认为它可以使用一些方向;)

基本上你只需要编辑 ~/.ssh/config 并确保用户名是 git 。您还可以告诉它使用 Github 的特定 SSH 密钥 - 我的 ~/.ssh/config 文件如下所示:

Host gh
    Hostname github.com
    User git
    IdentityFile ~/.ssh/github_rsa.pub

由于我有很多其他事情,我有一个 Github 的特定密钥我一整天都会这样做,但如果你只有一个,那么它通常会是 ~/.ssh/id_rsa.pub 就像 Github 在此解释

我知道每个人都有不同的解决方案,但我将把它留在这里给那些可能遇到这篇文章但没有修复的人。祝你好运!

I encountered this same problem, however the GIT_SSH solution appeared to work once for me. After a computer restart I realized it was something else, as I was able to clone my private repositories with no problem using Git Bash or Command Prompt, but not in Sublime Text 3 with the SublimeGit plugin. My solution was simple and is actually what @BlueRaja - Danny Pflughoeft mentioned but I thought it could use some direction ;)

Basically you just need to edit ~/.ssh/config and ensure the username is git. You can also tell it to use a specific SSH key for Github -- My ~/.ssh/config file looks like the following:

Host gh
    Hostname github.com
    User git
    IdentityFile ~/.ssh/github_rsa.pub

I have a specific key for Github due to the number of other things I do throughout my day, but if you've only got one then it usually will be ~/.ssh/id_rsa.pub like Github explains here.

I know everyone has a different solution, but I'll leave this here for anyone who may encounter this article without a fix. Good luck!

ゞ记忆︶ㄣ 2024-09-20 04:00:36

我在使用 TortoiseGit 从 GitHub 克隆存储库时遇到此错误。通过单击“加载 Putty 密钥”并在 Git 克隆对话框中选择密钥文件 (*.pkk) 来修复。

I got this error when using TortoiseGit to clone a repository from GitHub. Fixed by clicking "Load Putty Key" and selecting a key file (*.pkk) in the Git clone dialogue.

动听の歌 2024-09-20 04:00:36

在 Windows 10 中,如果您进行了包括 Putty 在内的典型安装,则上述解决方案都不适合我,我必须进入控制面板,特别是系统变量,将 GIT_SSH 更改为 D:\Program Files\Git\usr\bin \ssh.exe 在那里(它链接到 plink.exe 并且没有修改 .profile 或任何说服它改变它的东西,只编辑系统变量)。

In Windows 10, if you did a typical installation including Putty, none of the above solutions worked for me, I had to go into the control panel and specifically the system variables, changing GIT_SSH to D:\Program Files\Git\usr\bin\ssh.exe there (it was linking to plink.exe and no amount of modifying .profile or whatever convinced it to change that, only editing the system variables).

离笑几人歌 2024-09-20 04:00:36

您可以获得 plink &选美比赛从这里开始: http://www.chiark.greenend.org .uk/~sgtatham/putty/download.html

它们是 PuTTY 工具。

You can get plink & pageant from here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

They are PuTTY tools.

嘿哥们儿 2024-09-20 04:00:36

我遇到这个问题(直接 ssh 有效,但 git pull 失败),因为我的 git 远程不是我想象的那样。

是的,是的,我知道这是一个愚蠢的错误,但它确实发生了,值得检查。

使用 git Remote -v

I got this problem (direct ssh worked, but git pull failed) due to my git remote not being what I thought it was.

Yes, yes, I know it's a stupid mistake, but it happens and it's worth checking.

Use git remote -v

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文