github: No supported authentication methods available

匿名 (未验证) 提交于 2019-12-03 03:06:01

问题:

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 git@github.com 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 git@github.com 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.

回答1:

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 


回答2:

Using TortoiseGit

Set TortoiseGit > Settings > Network > SSH Client to C:\Program Files (x86)\Git\bin\ssh.exe or C:\Program Files\Git\usr\bin\ssh.exe



回答3:

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



回答4:

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)



回答5:

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?



回答6:

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: git@github.com: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


回答7:

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.



回答8:

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



回答9:

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



回答10:

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!



回答11:

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.



回答12:

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

They are PuTTY tools.



回答13:

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 


回答14:

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



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