github: No supported authentication methods available
Asked Answered
F

18

108

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.

Fluffy answered 7/8, 2010 at 17:11 Comment(0)
O
108

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
Optometer answered 1/10, 2010 at 18:57 Comment(8)
+1 I've had nothing but problems when using Putty/Pageant for git's ssh needs. Using the built in ssh client works wonders. This explains why ssh [email protected] returns fine if you execute it yourself, but letting git use the configured tools (Putty/Pageant) doesn't.Uzia
For me that's just GIT_SSH="/bin/ssh.exe" (on Windows). Thanks!Ignoble
Doesn't work, still gives putty fatal error that no supported auth methods are available.Kurys
@Kurys are you using the mingw32 prompt?Optometer
@MartinKonicek Using GIT_SSH="/bin/ssh.exe" inside Cygwin worked great for me. I wonder if this is a default? I may have overwritten it and if it's not a default, it should be!Intent
Using cygwin in Windows 7, the above answer worked but I needed to the GIT_SSH to .bash_profile and not .profileArmorial
Also fixes the problem when just using Git Bash without PuTTY.Almatadema
In my case with Windows 10 using Git Bash it is GIT_SSH="D:\Program Files\Git\usr\bin\ssh.exe"Palecek
I
50

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

Indiraindirect answered 3/8, 2015 at 14:44 Comment(1)
thanks. this worked. note: you might have to hunt around for exactly where 'ssh.exe' lives on a given machine. for me it was C:\Program Files\Git\usr\bin\ssh.exe (probably on an out-of-date machine)Giamo
T
12

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

Telecast answered 13/3, 2015 at 15:21 Comment(0)
U
8

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)

Unanswerable answered 11/10, 2011 at 13:14 Comment(1)
You remember correctly; I had the same issue, with GIT_SSH pointing to the 32-bit TortoiseSVN version of TortoisePlink.exe. Moving it over to TortoiseGit's version worked.Pregnancy
M
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

Mccully answered 15/6, 2016 at 14:51 Comment(1)
Yep, it's just that simple. All I will add is to confirm your GIT_SSH env variable is pointing to plink.exe, and you should be good to go.Coze
S
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: [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
Sulfur answered 20/6, 2016 at 8:32 Comment(1)
+ 'git config --global http.sslVerify false'Hispidulous
R
4

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?

Reyreyes answered 5/11, 2013 at 17:15 Comment(2)
When cloning a private repository, it'd be a URL such as [email protected]:username/Repository.git. I'm not entirely sure on the science behind it either but it seems git is a generic username for every Github accountBoo
PLink/Pageant works fine. This is the actual issue, and using something like ssh://[email protected]/myname/repo.git will work great. Nice work. As for why, I assume it's to lock down security. The 'git' user has its login disabled, so no one can break into the system that way. They have to have a valid key to even talk to Github, and once they have a valid key, they can match it against the user to log them in.Denna
T
4

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
Theretofore answered 14/10, 2016 at 2:18 Comment(0)
R
4

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.

Rainbolt answered 23/9, 2019 at 11:19 Comment(1)
Remember, you will probably have to do this each time you reboot your Windows PC - you might put Pageant into your startup folder as a shortcut with the correct command line argument to your private key file, but if you've set a password on your private key when you created it, you'll need to remember to right-click on the Pageant icon in your tool tray, select "Add key", and fill it in after each reboot.Tights
M
4

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?

Medieval answered 21/9, 2021 at 16:57 Comment(1)
This helped me resolve another issue described here: #33240637Threw
I
2

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.

Iraidairan answered 18/7, 2013 at 3:18 Comment(0)
Z
2

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

Zoology answered 24/12, 2019 at 11:27 Comment(0)
D
1

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

Dusty answered 17/2, 2011 at 19:7 Comment(0)
B
1

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!

Boo answered 15/10, 2014 at 1:1 Comment(0)
R
1

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.

Ropeway answered 14/7, 2015 at 12:9 Comment(0)
C
1

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

Caustic answered 17/6, 2021 at 10:49 Comment(1)
This is the only one that worked for me, after painstakingly applying every other more voted solution.Prescript
G
0

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

They are PuTTY tools.

Gerladina answered 18/8, 2010 at 3:24 Comment(0)
P
0

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

Processional answered 27/2, 2017 at 22:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.