Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...