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
684 views
in Technique[技术] by (71.8m points)

version control - "Cannot spawn ssh" when connecting to Github, but ssh -T git@github.com works?

I am having a hard time getting Github (+Netbeans to work).

I want to use ssh with git (on Windows 7) to, e.g., commit or clone a project, but I keep getting this error message :

$ git clone git@github.com:USER/PROJECTNAME.git
error: cannot spawn C:Program Files (x86)Gitinssh.exe: No such file or directory
fatal: unable to fork

Note: For now, my GIT_SSH environment variable is pointing to C:Program Files (x86)Gitinssh.exe, but I have also tried C:Program Files (x86)Gitin, erasing it entirely, pointing to putty's/plink's folder, and pointing to their executables, but still the same message.

When I test the connection everything works fine:

$ ssh -T git@github.com
Hi USER! You've successfully authenticated, but GitHub does not provide shell access.

What am I doing wrong? Does it make a difference if I do the git init in the directory in the first place?

EDIT:

This didn't help:

setting GIT_SSH to plink.exe and adding plink's path to PATH

**EDIT 2 **

result of command with GIT_TRACE=2

$ GIT_TRACE=2 git clone git@github.com:XXX/AffableBean
trace: built-in: git 'clone' 'git@github.com:XXX/AffableBean'
Cloning into 'AffableBean'...
trace: run_command: 'Plink.exe' '-batch' 'git@github.com' 'git-upload-pack '''XXX/AffableBean''''
error: cannot spawn Plink.exe: No such file or directory
fatal: unable to fork
See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

None of the answers so far worked for me. What ended up fixing this issue for me was removing quotes from my GIT_SSH variable and don't escape any characters at all, no MSYS path style (eg. /c/path to putty/plink.exe). Just enter the path normally, Git handles the quoting.

set GIT_SSH=C:path to puttyplink.exe

That's it. When using GIT_TRACE you can see that the variable gets quoted in the resulting command so:

  1. the added double quotes change the string passed to the command and

  2. the path is wrapped in single quotes so the spaces are ok.

Hope that helps someone.


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

...