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

5

5

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:

enter image description here

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?

Pessimism answered 15/7, 2020 at 15:19 Comment(0)
D
3

I'm using macOS and was able to fix this, but the order of things 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 [email protected]

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

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

Doleful answered 20/3, 2021 at 9:27 Comment(0)
P
1

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.

Premises answered 1/2, 2021 at 10:43 Comment(1)
@shayan-shafiq, much obliged for your edit. I didn't go too much into formatting as this is a rather old post and I wasn't sure a solution were still needed. Still, you are right, this looks better :-) Thanks again.Premises
T
0

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.

Trustbuster answered 16/7, 2020 at 5:35 Comment(3)
Thanks for trying, but it had no effect. I adjusted your variables to suit my code and launched Netbeans from the same Windows shell, but there was no improvement. I get the same incorrect credentials error.Pessimism
@Pessimism In that shell session (with the simplified path), do you have a ~/.ssh/id_rsa private key?Trustbuster
Good point! It's getting late here so I'll investigate that tomorrow. Thanks for the tip.Pessimism
F
0

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 "[email protected]/..." here. That might explain why the git clone command did work from the command line, but not in the wizard.

Fortyniner answered 10/10, 2020 at 2:48 Comment(0)
N
0

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.

Newsstand answered 11/10, 2020 at 10:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.