Skip to content
This repository has been archived by the owner on Oct 5, 2018. It is now read-only.

UnknownHostKey JSch #209

Closed
tannymanny opened this issue Jul 28, 2016 · 10 comments
Closed

UnknownHostKey JSch #209

tannymanny opened this issue Jul 28, 2016 · 10 comments

Comments

@tannymanny
Copy link

When running the gradle task i get this expcetion

What went wrong:
Execution failed for task ':cloneSomeRepo'.

org.eclipse.jgit.api.errors.InvalidRemoteException: Invalid remote: origin

my gradle task looks like

task cloneSomeRepo(type: com.palominolabs.gradle.task.git.clone.GitCloneTask) {
dir = file("../libToolkit_temp")
uri = 'https://@/.git'
treeish = 'master' // branch
}

@ajoberstar
Copy link
Owner

I would expect that JGit doesn't know how to handle this is a remote URL: https://@/.git.

@tannymanny
Copy link
Author

tannymanny commented Jul 29, 2016

Hi, sorry for the typo and thanks for your reply.

The URI is actually something like:
uri = "git@domain.com/path/repo.git"

My domain uses ssh verification. It works fine when I use the same uri for git cloning from commandline and other apps.

The new exception that I am getting now from the plugin is:

com.jcraft.jsch.JSchException: UnknownHostKey: domain.com RSA key fingerprint is 33:c0:e2:98:93:d2:a4:43:ec:98:60:5b:cd:ad:3b:b8

And I don't know where it is picking up that key fingerprint from.
This is not defined in my "known_hosts" file and also not the key I am using in the "id_rsa" files.

Do you know how i can fix this?

Thanks for the help

@tannymanny
Copy link
Author

Here is the exception from the --stacktrace option

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':cloneSomeRepo'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.internal.UncheckedException: com.jcraft.jsch.JSchException: UnknownHostKey: stash.cz.avg.com. RSA key fingerprint is 33:c0:e2:98:93:d2:a4:43:ec:98:60:5b
:cd:ad:3b:b8
        at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:45)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:78)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:227)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 14 more
Caused by: com.jcraft.jsch.JSchException: UnknownHostKey: stash.cz.avg.com. RSA key fingerprint is 33:c0:e2:98:93:d2:a4:43:ec:98:60:5b:cd:ad:3b:b8
        at com.jcraft.jsch.Session.checkHost(Session.java:797)
        at com.jcraft.jsch.Session.connect(Session.java:342)
        at com.jcraft.jsch.Session.connect(Session.java:183)
        at com.jcraft.jsch.Session$connect.call(Unknown Source)
        at com.palominolabs.gradle.task.git.clone.SshAgentSshSessionFactory.getSession(SshAgentSshSessionFactory.groovy:64)
        at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:136)
        at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:264)
        at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:162)
        at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136)
        at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122)
        at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1179)
        at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128)
        at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:76)
        at java_util_concurrent_Callable$call.call(Unknown Source)
        at com.palominolabs.gradle.task.git.clone.GitCloneTask.setUpRepo(GitCloneTask.groovy:102)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        ... 21 more

@ajoberstar
Copy link
Owner

So you're saying that's not the fingerprint of your actual host your remote URI points to?

If it is the right one, it just needs to be added to the known_hosts. If not, I'm a little unsure.

A workaround is to disable strict checking of hosts:

org.ajoberstar.grgit.auth.session.config.StrictHostKeyChecking=no

http://ajoberstar.org/grgit/docs/groovydoc/index.html?org/ajoberstar/grgit/auth/AuthConfig.html

@tannymanny
Copy link
Author

Yes this fingerprint is NOT the one for my remote URI.

SO should i add this line in my task definition? :
org.ajoberstar.grgit.auth.session.config.StrictHostKeyChecking=no

@ajoberstar
Copy link
Owner

It seems concerning that you're seeing a different host key, but if you trust that its still connecting to the right thing, disabling is the workaround for now.

That would need to be added as a system property. So either:

./gradlew -Dorg.ajoberstar.grgit.auth.session.config.StrictHostKeyChecking=no ...

or in gradle.properties:

systemProp.org.ajoberstar.grgit.auth.session.config.StrictHostKeyChecking=no

@tannymanny
Copy link
Author

Hi, thanks for your reply, but i am getting the same error even with StrictHostKeyChecking=no
It made no difference, i specified that in the gradle.properties file and also tried the commandline parameter. No idea where it is getting that key fingerprint from.

@ajoberstar
Copy link
Owner

Unfortuantely, not sure what to try next. This is probably related to the issues that have been reported in the past. There's some additional logging I could add, but I think it just needs more research into how JGit/JSch handle these host keys. In the near term I probably won't have a chance to do that, though certainly open to any feedback from someone who has the time.

@ajoberstar ajoberstar changed the title InvalidRemoteException: Invalid remote: origin UnknownHostKey JSch Aug 15, 2016
@ajoberstar
Copy link
Owner

ajoberstar commented Aug 16, 2016

This is going to be more of a grgit problem, so I've opened ajoberstar/grgit#123.

@ajoberstar
Copy link
Owner

This should be resolved with 1.7.0, which will be out tonight.

@ajoberstar ajoberstar added this to the 1.7.0 milestone Mar 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants