github: No supported authentication methods available
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.
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
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
"... 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.
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)