Navigation Menu

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

Git clone failing on ssh host key check #88

Closed
elfdude opened this issue Dec 3, 2014 · 2 comments
Closed

Git clone failing on ssh host key check #88

elfdude opened this issue Dec 3, 2014 · 2 comments

Comments

@elfdude
Copy link

elfdude commented Dec 3, 2014

I'm having an issue which is almost certainly something I'm doing wrong, but I can't for the life of me figure out what it is. I'm trying to use gradle-git to clone an internal git repo which has been in use by non-gradle clients for awhile. However whenever I try, I get derailed by the host key check. Not only have I checked to ensure that my known_hosts file exists where it should, but I also plugged l local copy of the jsch library (with System.out.printlns) so that I could nose around a bit. And when I did that it seems that nothing is telling jsch which knownHosts file to use. Which seems really odd as I wouldn't expect it to work for anyone if that were the case (so clearly it is not.)

Can someone tell me what stupid thing I'm doing wrong? Or am I possibly in some corner case?

error I get
What went wrong:
Execution failed for task ':cloneFromGit'.

ssh://fakeUser@fake.host.com:29418: org.eclipse.jgit.transport.CredentialItem$YesNoType:The authenticity of host 'fake.host.com' can't be established.
RSA key fingerprint is fake.key.fingerprint
Are you sure you want to continue connecting?

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':cloneFromGit'.
    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:42)
    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.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:58)
    Caused by: org.eclipse.jgit.errors.UnsupportedCredentialItem: ssh://ellumpki@n3pvap1003.1dc.com:29418: org.eclipse.jgit.transport.CredentialItem$YesNoType:The authenticity of host 'n3pvap1003.1dc.com' can't be established.
    RSA key fingerprint is 2d:d7:28:04:da:27:e1:52:e6:5b:83:e2:e2:0d:b8:26.
    Are you sure you want to continue connecting?
    at org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider.get(UsernamePasswordCredentialsProvider.java:118)
    at org.eclipse.jgit.transport.CredentialsProviderUserInfo.promptYesNo(CredentialsProviderUserInfo.java:124)
    at com.jcraft.jsch.Session.checkHost(Session.java:774)
    at com.jcraft.jsch.Session.connect(Session.java:342)
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
    at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:121)
    at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.(TransportGitSsh.java:248)
    at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:147)
    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:1111)
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:130)
    at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178)
    at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125)
    at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:83)
    at java_util_concurrent_Callable$call$0.call(Unknown Source)
    at org.ajoberstar.grgit.operation.CloneOp.call(CloneOp.groovy:104)
    at org.ajoberstar.grgit.operation.CloneOp.call(CloneOp.groovy)
    at java_util_concurrent_Callable$call.call(Unknown Source)
    at org.ajoberstar.grgit.util.OpSyntaxUtil.tryOp(OpSyntaxUtil.groovy:45)
    at org.ajoberstar.grgit.Grgit$__clinit__closure1.doCall(Grgit.groovy:198)
    at build_git_ddjtftpuahoidiuzcvl0pbmvr$_run_closure3.doCall(C:\dev\eclipse\workspaces\default\SnapStoreAndForward\SnapSFRest\build.git.gradle:35)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:548)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:529)
    at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:77)
    at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:73)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 47 more

how I invoke the gradle script
-b build.git.gradle cloneFromGit -Djna.boot.library.path= -Dorg.ajoberstar.grgit.auth.force=hardcoded -Dorg.ajoberstar.grgit.auth.username=fakeUid -Dorg.ajoberstar.grgit.auth.password=fakePwd

relevant portions of the gradle script
buildscript {
repositories {
#some internal maven repos...
}
dependencies {
classpath 'org.ajoberstar:gradle-git:0.12.0'
}
}

import org.ajoberstar.grgit.*

task cloneFromGit() << {
Grgit.clone(dir: 'some/gitRepo', uri: 'ssh://fakeUserName@fake.name.com:29418/FakeRepoName')
}

my gradle/JVM/OS environment

Gradle 2.2.1

Build time: 2014-11-24 09:45:35 UTC
Build number: none
Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a

Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_72 (Oracle Corporation 24.72-b04)
OS: Windows 7 6.1 amd64

@ajoberstar
Copy link
Owner

Just to confirm, since you didn't say it explicitly, is that host/fingerprint listed in your known_hosts.

There might be some options to have it prompt you interactively to make a yes/no choice. I already have something like this as a fallback if you don't provide hardcoded creds. If you try your build again without the hardcoded creds, you should get prompted for them and might also get prompted for the yes/no hosts decision.

FYI, I'm using AwtCredentialsProvider as the fallback in grgit to do the last-resort authentication. That's what I think might also cover the hosts question.

@elfdude
Copy link
Author

elfdude commented Dec 4, 2014

I do have the correct host key in my known_hosts file. I've confirmed that by using the Git Bash client to connect (it also happens to be the client which added the host key to the file.)

Per your suggestion I tried executing the build script with only the following params:

             -b build.git.gradle pushEarToGit -Djna.boot.library.path= 

And, as expected, it prompted me for whether to accept the host key via an AWT-looking window, and when I said yes it then used my pageant configuration to successfully complete the build (aka I was not prompted for creds.) However successive executions of the script in still prompts me to accept the host key each time.

I guess that in my troubleshooting yesterday I circled around, but never quite landed on this particular set of params/config such that I received the exception instead of the prompt. Thank you very much. I'm assuming that when I run this on my Linux CI environment that the ssh-agent impl will kick in, and in that situation the prompting won't be necessary.

Thanks!

@elfdude elfdude closed this as completed Dec 4, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants