General Software and Sytem Fixes

Fix Netbeans 8.0.2 Git Incorrect Credential Error

Submitted by Derwent Ready on Sunday, 04 October 2015

Netbeans Won't Access Git Repositories Over SSH?

OK so recently I had to reinstall my long running Raspberry Pi web/git server as it was constantly crashing. I decided to start from a fresh config and only copy back data. In doing so my SSH RSA key changed and I noticed that on my laptop I could no longer access the repositories on my server from Netbeans. I could access them using the same settings from tortoisegit and from Netbeans on my desktop. Nebeans was returning an "Invalid Credentials" error even though the credentials were definitely right. On my desktop Netbeans registered that the key had changed and asked me to update it but on my laptop it just sat there getting denied.

After a day or two of nearly pulling my hair out, finding plenty of threads online that came up explaining the issue but not really helping me solve it I finally had a brainwave. I checked on my hunch and it turned out to be right.

So here I hope is the solution that I hope will work for you. I noticed in my Netbeans messages.log file that there was an issue with a library called jsch. I found plenty of posts listing this as a previously known issue with Netbeans 7 and a specific old version of jsch but nothing for Netbeans 8.0.2. It turned out that the main difference between my laptop and my desktop was that my laptop was still running JDK 1.7 whereas my desktop was running JDK1.8.

The Problem

1. Netbeans won't let you access remote git repositories over SSH and gives you an "Incorrect Credentials" erorr. The same repositories might have been accessible before the server's RSA keys changed but aren't anymore.

2. Repositories are accessible from other git programs on the same computer/other computers pointing to a local issue rather than a server issue.

Steps To Take

1. In Netbeans go to Tools > Java Platforms then checkif JDK 1.8 is your default. If it is I'm sorry but I'm not sure what's wrong* :( Hopefully it's not cos it's quite simple to fix. Close Netbeans.

2. Download and install JDK 8 (I downloaded the 64 bit version)

3. Go to your Netbeans install location (Default on Windows will be C:/Program Files/Netbeans) then navigate to the etc folder and edit netbeans.conf (you will need to run Notepad or your favourite text editor in Administrator mode)

4. Find the section that reads something like:

netbeans_jdkhome="C:\Program Files\Java\jdk1.7.0_75

5. Replace that last part with the new JDK 8 directory. In my case the line now looks like:

netbeans_jdkhome="C:\Program Files\Java\jdk1.8.0_60

6. Open Netbeans and repeat Step 1. Hopefully it will now read JDK 1.8 (Default). If so, no need to close Netbeans. Go to a project with a git remote and try to access it. Hopefully if all has gone well you should now be able to access it like you should.

I think the issue is that the latest version of jsch has a bug when running under JDK 1.7 that's been fixed when it's running under JDK 1.8.

I hope this helps anyone suffering the same/similar problem to the one I had. It was VERY frsutrating. I have only had this problem/tried the fix on Windows but I suspect the same thing should work on Linux/Mac with the appropriate directories switched for their local counterparts.

* I read a few places on older versions of the same issue suggesting you go the jsch library homepage and download a different version to the one bundled with Netbeans. If you'd like to try this, download the file(s) and place them in your Netbeans module\ext folder. (Just search in the Netbeans installation folder for jsch to see what files you need to replace. There should be about 4 of them). If you installed Netbeans to the default Windows location it'll be C:\Program Files\NetBeans 8.0.2\ide\modules\ext.

If you liked this blog post, why not buy me a beverage?

Blog Appreciation: Usefulness
blog comments powered by Disqus