Search code examples
githubsshnetbeans-7ssh-keys

Netbeans fails to access GitHub using SSH key


My (newest) Netbeans (NetBeans IDE 7.3 (Build 201302132200)) seems to be failing completely, when I'm trying to access my own GitHub repo using SSH. It works without problems with HTTP URLs.

Since I've imported an existing local copy of GitHub repository (New > PHP Project with existing sources), created once with TortoiseGit, there were remote settings saved in local copy meta-data (probably in .git folder). So Netbeans offers option Select Configured Git Repository Location in Push to Remote Repository window. But is unsuccessful at that.

Tried following:

  1. When I'm using SSH URL ([email protected]:user/reponame.git) and Password option, with account pass, Netbeans tries to connect GitHub (remote) and after circa 5 seconds throws error Cannot connect to the remote repository at [email protected]:user/reponame.git.

  2. When using SSH URL with Private/Public Key option, Netbeans throws exactly the same error immediately, so I assume, that for some reason it doesn't even tries to connect GitHub.

What is even more strange (?), Netbeans is not asking for private key's passpharse. I've set it, but did not entered it to Netbeans deliberately, to test connection process. I was more than sure, that Netbeans will ask me to provide this passpharse, as it shouldn't be able to use private key without it. To my surprise, it hasn't asked for it and instead it thrown an error saying, that it can't connect GitHub. Of course, that was only a test. After entering correct passpharse, I'm getting exactly the same effects.

I've copied my repo's URL directly from GitHub website, without any modifications. It seems, that I can only use HTTP URL (https://github.com/user/reponame.git). This works and assures me that all items (URL, user, reponame, password, finally Internet connection) are OK. But, it seems, that Netbeans fails completely on SSH URL.

Above happens always, no matter if I select Select Configured Git Repository Location or Specify Git Repository Location in Push to Remote Repository window. No matter, what I'll do I can't access my repository via SSH in Netbeans and using HTTP is the only option.

I have created my private-public key pair using puttygen.exe from PuTTY's website. I saved private key in Netbeans installation directory and added public key to GitHub's SSH Settings page. I used step-by-step guide I normally use with TortoiseGit.

I don't know what else I could miss out or I'm doing wrong? Any idea?


Solution

  • After series of many tests, I found out that Netbeans:

    1. Does not work to well with existing local copies of GitHub (or any other git) remote repositories.

    2. Does not work at all with SSH keys generated by puttygen.

    As for first, I had to remove entire folder cloned with TortoiseGit and clone the same repository using Netbeans-bundled tools (Team > Git > Clone). The same goes for Subversion (look here) -- so the general rule of thumb says, that when you're switching from another Git or SVN client to Netbeans, you should do a full, clean clone (or checkout) of remote repository as attempts to re-use existing copy will most likely fail.

    As for second, follow instructions given in this GitHub article and use ssh-keygen (either from your local installation of Git for Windows, in case of Windows or from any other source) instead of puttygen -- SSH keys generated by it can't be used in Netbeans for setting up password-less login to GitHub.

    As I wrote, I've been using TortoiseGit previously, which accepts and works well with puttygen keys, so it wasn't to obvious for me, that source of the problem is here.

    After fixing this two problems (getting clean clone and generating correct keys), ale problems expressed in my question were gone and Netbeans works with GitHub repositories like a charm.