简体   繁体   中英

Cannot use Team -> Git -> Clone wizard in Netbeans 12 to connect to a github repo using SSH

I'm running Apache Netbeans 12 on Windows and I'm really struggling to connect to my github repositories using an SSH connection. I get the strong impression that this has been a problem for Netbeans users for a long time. What I've tried so far:

  • I installed openSSH in the Cygwin I use to run a terminal within Netbeans. This allowed me to use ssh-agent.
  • I attempted to get ssh-agent running and add the relevant private key that matches the public key in my Git repo.
  • I have no trouble cloning this repo using git bash and a standalone Cygwin shell (now that I have ssh-agent running), but the Team->Git->Glone wizard in Netbeans gives me this connection error:

在此处输入图像描述

Dev builds, but true as long as I can remember. I am unable to use NetBeans to perform any Git operations requiring SSH authentication: pushing to GitHub, pulling from a private repository, etc. The same operations using command-line Git work fine, but in NetBeans I am prompted for a username and password, or for a private key with passphrase. This is unnecessary from the command line as I use ssh-agent to unlock my private key without needing to type in the passphrase every time; apparently the Git library used by NB does not manage to communicate with ssh-agent so it fails.

This is the kind of response (about Netbeans 7 remember, I'm still struggling with version 12) which I find frustrating:

“Seems that the automatic use of ssh-agent is now working; maybe was only broken for repositories which I had tried to push/pull from in NetBeans prior to this fix.”

Not it's not. I simply can't get Netbeans to clone a github repository following the standard wizard documentation.

John Gibson commented on GitLab CE issue #624 ( https://gitlab.com/gitlab-org/gitlab-ce/issues/624#note_299061 ) that he encountered a similar error. He explains that he "discovered that all of the available ciphers on the server were at least 256 bits. Standard Oracle Java ships with crypto that's restricted to 128 bits for some algorithms. After installing the unlimited strength crypto package from Oracle the issue went away. Note that the unlimited strength package is only legally available in the US. If you're outside of the US then I think that OpenJDK will work instead."

I followed the link he mentioned ( http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html ), downloaded the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 7 and followed the steps in the readme-file that came with the download.

  • I tried this download and the readme.txt clearly states:

“Current versions of the JDK do not require separate unlimited policy files. They are provided for use with older versions. The unlimited policy files for earlier releases are required only for JDK 7 updates earlier than 7u171.”

So, that doesn't work either. I am absolutely stumped. What do I have to do to get the latest, shiniest version of Netbeans to work smoothly with github and SSH connections?

I had the same problem and after a long search I found how to solve it. It is about the way private keys are generated.

Check this .

I'm using macOS and was able to fix this, but the order of thing is a bit tricky.

First go to the SSH folder and delete the known hosts (or remove the GitHub section from it):

cd ~/.ssh
rm known_hosts

Then change the key format as explained in "Invalid privatekey" when using JSch :

cp yourkeyfile yourkeyfile.bak
ssh-keygen -p -f yourkeyfile -m pem

Then verify it is working (enter yes when asked to continue, which creates the known hosts file again):

ssh -T git@github.com

Close NetBeans if it is still running and start it again.

In the clone dialog leave the key and passphrase fields blank.

Try without Cygwin at all.

Launch Netbeans in a simplified path which includes only:

  • Windows
  • Java
  • Git

That is:

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%
set PATH=C:\path\to\java\bin;%PATH%

Git for Windows itself includes everything you need for OpenSSH to work.

I'm not sure if this helps, but I also had problems to clone a repository with the NetBeans wizard, but they disappeared on the next day, probably because of rebooting Windows or restarting NetBeans. It also seems that NetBeans does not support any abbreviations you might have defined in the.ssh/config. So you got to use the long form "user@hosturl.xx/..." here. That might explain why the git clone command did work from the command line, but not in the wizard.

I had a similar problem, I believe, but on MacOS. For me the solution was to change the permissions on the id_rsa file, as suggested here , to 400 , which means read-only access for the owner and no access at all for anyone else. Not sure how to set the equivalent permissions on Windows, but it might help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM