This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 199263 - Cannot connect to remote repositories with just ssh public/private keys
Summary: Cannot connect to remote repositories with just ssh public/private keys
Status: RESOLVED FIXED
Alias: None
Product: versioncontrol
Classification: Unclassified
Component: Git (show other bugs)
Version: 7.0.1
Hardware: All All
: P3 normal with 8 votes (vote)
Assignee: Ondrej Vrabec
URL:
Keywords:
: 201505 205850 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-06-08 12:14 UTC by Ondrej Vrabec
Modified: 2013-05-29 09:48 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Messages log file (3.77 KB, application/octet-stream)
2012-02-17 05:04 UTC, lazyguru
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Vrabec 2011-06-08 12:14:35 UTC
Try e.g. git@github.com:tstupka/koliba.git
Comment 1 kincera 2011-08-19 16:19:25 UTC
I get this for both https and ssh attempts to connect to github:

401 Authorization Required

This is despite the fact that I have put in the proper credentials.
Comment 2 Quality Engineering 2011-08-26 14:41:24 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/c4ab635b1b79
User: Ondrej Vrabec <ovrabec@netbeans.org>
Log: Issue #199263 - Cannot connect to remote repositories with just ssh public/private keys
Comment 3 Ondrej Vrabec 2011-08-29 14:59:20 UTC
fix: http://hg.netbeans.org/core-main/rev/b83c110776d5
Comment 4 Ondrej Vrabec 2011-08-29 15:01:31 UTC
I was able to push to java.net with private/public ssh keys. I guess github behaves the same, but i cannot check since i am behind proxy. Someone please verify SSH connection works.
Comment 5 Quality Engineering 2011-08-30 14:23:44 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/b83c110776d5
User: Ondrej Vrabec <ovrabec@netbeans.org>
Log: #199263 - Cannot connect to remote repositories with just ssh public/private keys
URL should be trimmed
Comment 6 Ondrej Vrabec 2011-09-01 08:06:35 UTC
*** Bug 201505 has been marked as a duplicate of this bug. ***
Comment 7 kincera 2011-09-03 18:58:32 UTC
I'm not sure I know how to patch the plugin with this code to test.
Comment 8 Ondrej Vrabec 2011-09-03 19:47:05 UTC
(In reply to comment #7)
> I'm not sure I know how to patch the plugin with this code to test.
You need to download and try a dev build; http://bits.netbeans.org/download/trunk/nightly/latest/
Comment 9 topherdan1 2011-09-05 03:27:22 UTC
I just downloaded the latest dev version. I used a Github URL, similar to the orginal bug report and setup public/private key access within Netbeans. When I tried to Clone the repository, I received this error "invalid privatekey:" with a reference to the private key location. I tried this after using a private key both with and without a password and received the same result. I am using PuttyGen to create the keys.
Comment 10 Ondrej Vrabec 2011-09-05 07:24:38 UTC
(In reply to comment #9)
Please attach the message log, there should be more info regarding the error.
Comment 11 Ondrej Vrabec 2011-09-05 07:50:44 UTC
And let me know the type of the private key: paste the header here, e.g.:
> -----BEGIN DSA PRIVATE KEY-----
> Proc-Type: 4,ENCRYPTED
> DEK-Info: AES-128-CBC,E2112EB163340654D6DE14EA435ADD82
Looking into the code it seems that jsch lib thinks your key is different from DSA and RSA.
Comment 12 topherdan1 2011-09-05 16:10:01 UTC
I tried both RSA and DSA keys generated from PuttyGen. Here is the header of the SSH-2 DSA private key file with no password:


PuTTY-User-Key-File-2: ssh-dss
Encryption: none
Comment: dsa-key-20110905
Public-Lines: 10
...

Here is a the header from the RSA key:

PuTTY-User-Key-File-2: ssh-rsa
Encryption: none
Comment: rsa-key-20110905
Public-Lines: 4
AAAAB3NzaC1yc2EAAAABJQAAAIBapuPpBoVMJDzcz2WKWzNXy/TJVdOCwn9jTFhW
meeaG4CX1OrNypF4BIVriTuWmOdW0QH/oQMhWmQjjs20XHd4PopZB2Hg2s1ntq/A
g/fakzR4Rc1/5FEOd/4dGjGbibkiC3nsELvmBkbf2YVY0+JeHTG3XRs4J0P+Rs7T
OL8ZaQ==
Private-Lines: 8
....

Here is the message log data:

INFO [org.netbeans.modules.git]: git@github.com:user105/html5-boilerplate.git: invalid privatekey: C:\Users\user105\github.ppk
com.jcraft.jsch.JSchException: invalid privatekey: C:\Users\user105\github.ppk
	at com.jcraft.jsch.IdentityFile.<init>(IdentityFile.java:261)
	at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:135)
	at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:130)
	at com.jcraft.jsch.JSch.addIdentity(JSch.java:206)
	at com.jcraft.jsch.JSch.addIdentity(JSch.java:192)
	at org.netbeans.libs.git.jgit.JGitSshSessionFactory.getSession(JGitSshSessionFactory.java:99)
Caused: org.eclipse.jgit.errors.TransportException: git@github.com:user105/html5-boilerplate.git: invalid privatekey: C:\Users\user105\github.ppk
	at org.netbeans.libs.git.jgit.JGitSshSessionFactory.getSession(JGitSshSessionFactory.java:101)
	at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
	at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248)
	at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
	at org.netbeans.libs.git.jgit.commands.ListRemoteObjectsCommand.run(ListRemoteObjectsCommand.java:72)
Caused: org.netbeans.libs.git.GitException$AuthorizationException: git@github.com:user105/html5-boilerplate.git: invalid privatekey: C:\Users\user105\github.ppk
	at org.netbeans.libs.git.jgit.commands.TransportCommand.handleException(TransportCommand.java:159)
	at org.netbeans.libs.git.jgit.commands.ListRemoteObjectsCommand.run(ListRemoteObjectsCommand.java:79)
	at org.netbeans.libs.git.jgit.commands.GitCommand.execute(GitCommand.java:68)
	at org.netbeans.libs.git.jgit.JGitClient.listRemoteBranches(JGitClient.java:414)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.netbeans.modules.git.client.GitClientInvocationHandler.invokeClientMethod(GitClientInvocationHandler.java:259)
	at org.netbeans.modules.git.client.GitClientInvocationHandler.access$400(GitClientInvocationHandler.java:65)
	at org.netbeans.modules.git.client.GitClientInvocationHandler$1.call(GitClientInvocationHandler.java:211)
	at org.netbeans.modules.git.client.GitClientInvocationHandler.invokeIntern(GitClientInvocationHandler.java:243)
	at org.netbeans.modules.git.client.GitClientInvocationHandler.invoke(GitClientInvocationHandler.java:191)
	at $Proxy24.listRemoteBranches(Unknown Source)
[catch] at org.netbeans.modules.git.ui.clone.RepositoryStep$RepositoryStepProgressSupport.perform(RepositoryStep.java:190)
	at org.netbeans.modules.git.client.GitProgressSupport.performIntern(GitProgressSupport.java:101)
	at org.netbeans.modules.git.client.GitProgressSupport.run(GitProgressSupport.java:94)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1424)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1973)
Comment 13 Ondrej Vrabec 2011-09-05 18:29:17 UTC
(In reply to comment #12)
> PuTTY-User-Key-File-2: ssh-dss
> Encryption: none
> Comment: dsa-key-20110905
> Public-Lines: 10
PuTTY format won't work in NetBeans, you'll need to export the keys to the OpenSSH format which JSCh understands.
Comment 14 topherdan1 2011-09-06 00:55:16 UTC
Thanks ovrabec! I was able to use PuttyGen to create an SSH-2 RSA key with no password and it worked with Github and Beanstalkapp when I went to Conversions > Export OpenSSH key in PuttyGen and used that private key. 

Oddly, when I tried to add a password to the key and export it using PuttyGen, in Netbeans I received an Auth Failed error. 

It is now working well enough for me to use, but just in case this Auth Failed issue is worth looking into, here is the error from the message log:

com.jcraft.jsch.JSchException: Auth cancel
	at com.jcraft.jsch.Session.connect(Session.java:460)
	at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:128)
Caused: org.eclipse.jgit.errors.TransportException: git@github.com:user105/html5-boilerplate.git: Auth cancel
	at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:138)
	at org.netbeans.libs.git.jgit.JGitSshSessionFactory.getSession(JGitSshSessionFactory.java:105)
	at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
	at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:248)
	at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
	at org.netbeans.libs.git.jgit.commands.ListRemoteObjectsCommand.run(ListRemoteObjectsCommand.java:72)
Caused: org.netbeans.libs.git.GitException$AuthorizationException: git@github.com:user105/html5-boilerplate.git: Auth cancel
	at org.netbeans.libs.git.jgit.commands.TransportCommand.handleException(TransportCommand.java:157)
	at org.netbeans.libs.git.jgit.commands.ListRemoteObjectsCommand.run(ListRemoteObjectsCommand.java:79)
	at org.netbeans.libs.git.jgit.commands.GitCommand.execute(GitCommand.java:68)
	at org.netbeans.libs.git.jgit.JGitClient.listRemoteBranches(JGitClient.java:414)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.netbeans.modules.git.client.GitClientInvocationHandler.invokeClientMethod(GitClientInvocationHandler.java:259)
	at org.netbeans.modules.git.client.GitClientInvocationHandler.access$400(GitClientInvocationHandler.java:65)
	at org.netbeans.modules.git.client.GitClientInvocationHandler$1.call(GitClientInvocationHandler.java:211)
	at org.netbeans.modules.git.client.GitClientInvocationHandler.invokeIntern(GitClientInvocationHandler.java:243)
	at org.netbeans.modules.git.client.GitClientInvocationHandler.invoke(GitClientInvocationHandler.java:191)
	at $Proxy24.listRemoteBranches(Unknown Source)
[catch] at org.netbeans.modules.git.ui.clone.RepositoryStep$RepositoryStepProgressSupport.perform(RepositoryStep.java:190)
	at org.netbeans.modules.git.client.GitProgressSupport.performIntern(GitProgressSupport.java:101)
	at org.netbeans.modules.git.client.GitProgressSupport.run(GitProgressSupport.java:94)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1424)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1973)
Comment 15 Ondrej Vrabec 2011-09-06 06:09:48 UTC
> It is now working well enough for me to use, but just in case this Auth Failed
> issue is worth looking into, here is the error from the message log:
That's probably because jsch failed to unlock the private key. Did you try to connect with the same file (in OpenSSH format) on commandline?
Comment 16 topherdan1 2011-09-06 11:49:20 UTC
I didn't actually try it on the command line, so I'm not sure about the results there.
Comment 17 kincera 2011-09-23 19:00:31 UTC
Using an SSH key with no passphrase worked for me too.

Using one WITH a passphrase . . . not so much.

Also, there is a visual anomaly on mine where if I click on the keys option, the file name and passphrase box don't show up. I have to drag the bottom of the window down to see it.
Comment 18 rebizu 2011-12-02 14:42:52 UTC
*** Bug 205850 has been marked as a duplicate of this bug. ***
Comment 19 lazyguru 2012-02-16 18:50:14 UTC
Not sure why it would be acceptable to mark this as resolved when you can't connect with a private key that has a passphrase.  Removing the passphrase from a private key is moronic and goes against any security recommendations (it's like locking your house door, but leaving the key in the door).

I am seeing this issue in 7.1 (Build 201112071828) on Mac.

I am connecting to a repository via SSH and a private key with a passphrase.

Let me know what other details you need to track down and resolve this issue.
Comment 20 Ondrej Vrabec 2012-02-16 23:14:58 UTC
(In reply to comment #19)
I don't know what makes you think we support only ssh keys with empty passphrase. That's not true, i connect to github successfully with a identity file protected with a passphrase.
If you can't, attach the messages log with the detailed error description.
Comment 21 lazyguru 2012-02-17 05:04:26 UTC
Created attachment 115849 [details]
Messages log file
Comment 22 lazyguru 2012-02-17 05:04:45 UTC
This: http://netbeans.org/bugzilla/show_bug.cgi?id=199263#c17
and this: http://netbeans.org/bugzilla/show_bug.cgi?id=199263#c14
and this: http://netbeans.org/bugzilla/show_bug.cgi?id=205850#c2
And the fact the ticket was closed with no comments about it working with passphrases are what lead me to that conclusion (whether it was accurate or not).

I've attached the relevant part of the message log.

The /var/log/secure file from the server reports this message:

Feb 16 22:46:46 myhost sshd[3866]: Received disconnect from X.X.X.X: 3: com.jcraft.jsch.JSchException: Auth cancel
Comment 23 lazyguru 2012-02-17 05:22:53 UTC
I'm not sure why, but now it is working.
Comment 24 mbrowne 2012-07-16 18:57:09 UTC
It seems to be fixed in Netbeans 7.2 RC1
Comment 25 phr3n1c 2012-10-09 11:58:45 UTC
Sorry for reopening this issue, but I still have this issue with nb 7.2 and 7.3 beta.

I'm using ssh with key (exported puttygen key /w password). I'm using Git Extensions and 'git flow' in parallel. After cloning the repo nb git(hub) integration works well for some time, but after a while I get the message "Cannot connect to the remote repository at git@github.com:torstenfeld/ghrello.git

I got the same issue on connection to github:enterprise.
Comment 26 Ondrej Vrabec 2012-10-09 12:04:59 UTC
(In reply to comment #25)
> Sorry for reopening this issue, but I still have this issue with nb 7.2 and 7.3
> beta.
> 
> I'm using ssh with key (exported puttygen key /w password). I'm using Git
> Extensions and 'git flow' in parallel. After cloning the repo nb git(hub)
> integration works well for some time, but after a while I get the message
> "Cannot connect to the remote repository at
> git@github.com:torstenfeld/ghrello.git
> 
> I got the same issue on connection to github:enterprise.
Are you sure the key is exported in OpenSSH format?
Did you double check that you entered "git" into the username field?
> integration works well for some time
what does this mean? Can you pull, push, fetch??
> but after a while I get the message
> "Cannot connect to the remote repository at
> git@github.com:torstenfeld/ghrello.git
attach the full messages.log with the error
Comment 27 Ondrej Vrabec 2012-10-09 13:31:25 UTC
anyway, file another bug for your issue. I believe this is really fixed - no one has reopened this with valid foundations for over a year - your problem will probably lie somewhere else and let's not pollute this issue any more
Comment 28 fdisk 2013-05-10 07:38:47 UTC
trying to connect but got /// slashed - why not // ?
http://d.pr/i/YJXg
Comment 29 Ondrej Vrabec 2013-05-10 07:50:00 UTC
(In reply to comment #28)
> trying to connect but got /// slashed - why not // ?
> http://d.pr/i/YJXg
We (JGit to be precise) do not support this kind of URL: #226607. Use git@dev:repositories/wl2
Comment 30 hubik.tomas 2013-05-29 01:06:24 UTC
I have the similar problem. I am trying to connect to my gitolite repository through ssh on Windows 7, NetBeans 7.3. My server is running gitolite3 v3.5-0-g4071623 on git 1.7.1.

When connecting through Git Extensions, everything works without any problem. When trying to connect through NetBeans, I get some errors.

URL: redmine.domain.cz:repodir/repo_1.git
Username: git
Private key: D:\Dokumenty\Keys\user.ppk

Clone:
Error: git@redmine.domain.cz:repodir/repo_1.git: Auth cancel

Pull:
Still asking for URL and keys. When I click cancel I get:
Cannot connect to the remote repository at git@redmine.domain.cz:repodir/repo_1.git

Could anyone help with this problem?
Comment 31 Ondrej Vrabec 2013-05-29 07:43:25 UTC
> Private key: D:\Dokumenty\Keys\user.ppk
this is suspicious: are you sure the key is in the OpenSSH format? Please note that our internals can work only with OpenSSH format: it's mentioned in the guide: https://netbeans.org/kb/docs/ide/git.html#github
Comment 32 hubik.tomas 2013-05-29 09:41:57 UTC
(In reply to comment #31)
> > Private key: D:\Dokumenty\Keys\user.ppk
> this is suspicious: are you sure the key is in the OpenSSH format? Please note
> that our internals can work only with OpenSSH format: it's mentioned in the
> guide: https://netbeans.org/kb/docs/ide/git.html#github

I generated my keys in the Puttygen, but they are causing another error:
git@redmine.domain.cz:repodir/repo_1.git: invalid privatekey: D:\Dokumenty\Keys\admin-putty.ppk

So I converted it manually into OpenSSH format and there I made the mistake. I converted it badly. Now I tried to open the private key in the PuttyGen and export it as OpenSSH key using it and everything works fine.

Thank you for your help.
Comment 33 Ondrej Vrabec 2013-05-29 09:48:58 UTC
Also note that in 7.4 the git support should be able to communicate with ssh-agent and paegeant directly and there should be no need to export to openssh format. So if you correctly setup paegeant on windows and import the key to the tool the git support should connect automatically without need to specify the key file or passphrase. See bug #218918 for more info